app/jobs/bulkrax/create_relationships_job.rb in bulkrax-3.4.0 vs app/jobs/bulkrax/create_relationships_job.rb in bulkrax-3.5.0
- old
+ new
@@ -40,13 +40,15 @@
@parent_entry, @parent_record = find_record(parent_identifier, importer_run_id)
@child_records = { works: [], collections: [] }
pending_relationships.each do |rel|
raise ::StandardError, %("#{rel}" needs either a child or a parent to create a relationship) if rel.child_id.nil? || rel.parent_id.nil?
@child_entry, child_record = find_record(rel.child_id, importer_run_id)
- child_record.is_a?(::Collection) ? @child_records[:collections] << child_record : @child_records[:works] << child_record
+ if child_record
+ child_record.is_a?(::Collection) ? @child_records[:collections] << child_record : @child_records[:works] << child_record
+ end
end
- if (child_records[:collections].blank? && child_records[:works].blank?) || parent_record.blank?
+ if (child_records[:collections].blank? && child_records[:works].blank?) || parent_record.nil?
reschedule({ parent_identifier: parent_identifier, importer_run_id: importer_run_id })
return false # stop current job from continuing to run after rescheduling
end
@parent_entry ||= Bulkrax::Entry.where(identifier: parent_identifier,
importerexporter_id: ImporterRun.find(importer_run_id).importer_id,