Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Adds MyReindex to assist with SOLR upgrade. #1166

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions lib/tasks/reindex.rake
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# frozen_string_literal: true
namespace :reindex do
desc "Reindex specified work, e.g., rake myreindex:reindex_by_id['c821gj76b']"
task :reindex_by_id, [:id] => :environment do |_, args|
object = find_or_warn(args[:id]) || next

if object.id.blank?
$stderr.puts "No such work exists for id: #{object.id}"
next
else
ActiveFedora::Base.find(object.id).update_index
puts "Reindexed work id #{object.id}"
end
end

desc "Reindex collections"
task reindex_collections: :environment do
count = 0
Collection.all.each do |object|
if object.id.blank?
$stderr.puts "No such work exists for id: #{object.id}"
next
else
ActiveFedora::Base.find(object.id).update_index
count += 1
end
end
puts "Reindexed works for #{count} objects"
end

desc "Reindex all objects"
task reindex_works: :environment do
count = 0
[Image, Document, ExternalObject, MedSym, Review].each do |model_class|
model_class.all.each do |object|
if object.id.blank?
$stderr.puts "No such work exists for id: #{object.id}"
next
else
ActiveFedora::Base.find(object.id).update_index
count += 1
end
end
end
puts "Reindexed works for #{count} objects"
end
end