app/jobs/bulkrax/create_relationships_job.rb in bulkrax-3.0.0 vs app/jobs/bulkrax/create_relationships_job.rb in bulkrax-3.0.1
- old
+ new
@@ -80,38 +80,36 @@
end
# Work-Collection membership is added to the child as member_of_collection_ids
# This is adding the reverse relationship, from the child to the parent
def collection_parent_work_child
- child_records[:works].each do |child_record|
- ::Hyrax::Collections::NestedCollectionPersistenceService.persist_nested_collection_for(parent: parent_record, child: child_record)
- # TODO: add counters for :processed_parents and :failed_parents
- Bulkrax::ImporterRun.find(importer_run_id).increment!(:processed_relationships) # rubocop:disable Rails/SkipsModelValidations
- end
+ child_work_ids = child_records[:works].map(&:id)
+ parent_record.reindex_extent = Hyrax::Adapters::NestingIndexAdapter::LIMITED_REINDEX
+
+ parent_record.add_member_objects(child_work_ids)
+ ImporterRun.find(importer_run_id).increment!(:processed_relationships, child_work_ids.count) # rubocop:disable Rails/SkipsModelValidations
end
# Collection-Collection membership is added to the as member_ids
def collection_parent_collection_child
child_records[:collections].each do |child_record|
::Hyrax::Collections::NestedCollectionPersistenceService.persist_nested_collection_for(parent: parent_record, child: child_record)
- Bulkrax::ImporterRun.find(importer_run_id).increment!(:processed_relationships) # rubocop:disable Rails/SkipsModelValidations
+ ImporterRun.find(importer_run_id).increment!(:processed_relationships) # rubocop:disable Rails/SkipsModelValidations
end
end
# Work-Work membership is added to the parent as member_ids
def work_parent_work_child
records_hash = {}
child_records[:works].each_with_index do |child_record, i|
records_hash[i] = { id: child_record.id }
end
- attrs = {
- work_members_attributes: records_hash
- }
- parent_record.reindex_extent = Hyrax::Adapters::NestingIndexAdapter::LIMITED_REINDEX if parent_record.respond_to?(:reindex_extent)
+ attrs = { work_members_attributes: records_hash }
+ parent_record.try(:reindex_extent=, Hyrax::Adapters::NestingIndexAdapter::LIMITED_REINDEX)
env = Hyrax::Actors::Environment.new(parent_record, Ability.new(user), attrs)
+
Hyrax::CurationConcern.actor.update(env)
- # TODO: add counters for :processed_parents and :failed_parents
- Bulkrax::ImporterRun.find(importer_run_id).increment!(:processed_relationships) # rubocop:disable Rails/SkipsModelValidations
+ ImporterRun.find(importer_run_id).increment!(:processed_relationships, child_records[:works].count) # rubocop:disable Rails/SkipsModelValidations
end
def reschedule(parent_identifier:, importer_run_id:)
CreateRelationshipsJob.set(wait: 10.minutes).perform_later(
parent_identifier: parent_identifier,