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

Lazy migrate sipity entity with work #7039

Merged
Merged
Show file tree
Hide file tree
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
15 changes: 15 additions & 0 deletions app/jobs/migrate_sipity_entity_job.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# frozen_string_literal: true

# migrates a resource's sipity entity so it can be found
class MigrateSipityEntityJob < ApplicationJob
# input [String] id of a migrated resource
def perform(id:)
resource = Hyrax.query_service.find_by(id: id)
new_gid = Hyrax::GlobalID(resource).to_s
work = resource.internal_resource.constantize.find(id)
original_gid = Hyrax::GlobalID(work).to_s
return if new_gid == original_gid
original_entity = Sipity::Entity.find_by(proxy_for_global_id: original_gid)
original_entity.update(proxy_for_global_id: new_gid)
end
end
1 change: 1 addition & 0 deletions lib/freyja/persister.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ def convert_and_migrate_resource(orm_object)
if new_resource.is_a?(Hyrax::Work)
member_ids = new_resource.member_ids.map(&:to_s)
MigrateResourcesJob.perform_later(ids: member_ids) unless member_ids.empty?
MigrateSipityEntityJob.perform_later(id: new_resource.id)
end
end
new_resource
Expand Down
Loading