Skip to content

Commit

Permalink
Valkyrize reindex rake tasks
Browse files Browse the repository at this point in the history
This commit adds reindexing for Valkyrie objects.

Issue:
- scientist-softserv/hykuup_knapsack#146

Co-Authored-By: Kirk Wang <[email protected]>
  • Loading branch information
ShanaLMoore and kirkkwang committed Feb 5, 2024
1 parent 6516b00 commit 7b32e43
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
6 changes: 5 additions & 1 deletion app/jobs/reindex_item_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

class ReindexItemJob < ApplicationJob
def perform(item)
item.update_index
if item.is_a?(Valkyrie::Resource)
Hyrax.index_adapter.save(resource: item)
else
item.update_index
end
end
end
6 changes: 5 additions & 1 deletion app/jobs/reindex_works_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@
class ReindexWorksJob < ApplicationJob
def perform(work = nil)
if work.present?
work.update_index
if work.is_a?(Valkyrie::Resource)
Hyrax.index_adapter.save(resource: work)
else
work.update_index
end
else
Site.instance.available_works.each do |work_type|
work_type.constantize.find_each do |w|
Expand Down
2 changes: 2 additions & 0 deletions lib/tasks/index.rake
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ task index_collections: :environment do
end
end

# TODO: handle valkyrie reindex once admin sets have been valkyrized
# ref: https://github.com/scientist-softserv/hykuup_knapsack/issues/94
desc "reindex just the admin_sets in the background"
task index_admin_sets: :environment do
Account.find_each do |account|
Expand Down

0 comments on commit 7b32e43

Please sign in to comment.