-
Notifications
You must be signed in to change notification settings - Fork 21
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
accurate-relationship-forming #454
Changes from 9 commits
6e1b7a9
811c62d
5eab004
09fb636
1577ee7
6ff5f24
32ac4bd
db91c48
1cdc1ac
4c1732d
30c8cfc
7dc4ca2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,11 +37,11 @@ def perform(parent_identifier:, importer_run_id:) | |
end.sort_by(&:order) | ||
|
||
@importer_run_id = importer_run_id | ||
@parent_record = find_record(parent_identifier) | ||
@parent_entry, @parent_record = find_record(parent_identifier, importer_run_id) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. example use case that made this necessary: |
||
@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_record = find_record(rel.child_id) | ||
_, 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 | ||
end | ||
|
||
|
@@ -53,7 +53,7 @@ def perform(parent_identifier:, importer_run_id:) | |
return false # stop current job from continuing to run after rescheduling | ||
end | ||
|
||
@parent_entry = Bulkrax::Entry.where(identifier: parent_identifier, | ||
@parent_entry ||= Bulkrax::Entry.where(identifier: parent_identifier, | ||
importerexporter_id: ImporterRun.find(importer_run_id).importer_id, | ||
importerexporter_type: "Bulkrax::Importer").first | ||
create_relationships | ||
|
@@ -91,7 +91,8 @@ def collection_parent_work_child | |
related_parents_parsed_mapping: parent_entry.parser.related_parents_parsed_mapping, | ||
replace_files: false, | ||
user: user, | ||
klass: child_record.class | ||
klass: child_record.class, | ||
importer_run_id: importer_run_id | ||
).run | ||
# TODO: add counters for :processed_parents and :failed_parents | ||
Bulkrax::ImporterRun.find(importer_run_id).increment!(:processed_relationships) # rubocop:disable Rails/SkipsModelValidations | ||
|
@@ -109,7 +110,8 @@ def collection_parent_collection_child | |
related_parents_parsed_mapping: parent_entry.parser.related_parents_parsed_mapping, | ||
replace_files: false, | ||
user: user, | ||
klass: parent_record.class | ||
klass: parent_record.class, | ||
importer_run_id: importer_run_id | ||
).run | ||
# TODO: add counters for :processed_parents and :failed_parents | ||
Bulkrax::ImporterRun.find(importer_run_id).increment!(:processed_relationships) # rubocop:disable Rails/SkipsModelValidations | ||
|
@@ -132,7 +134,8 @@ def work_parent_work_child | |
related_parents_parsed_mapping: parent_entry.parser.related_parents_parsed_mapping, | ||
replace_files: false, | ||
user: user, | ||
klass: parent_record.class | ||
klass: parent_record.class, | ||
importer_run_id: importer_run_id | ||
).run | ||
# TODO: add counters for :processed_parents and :failed_parents | ||
Bulkrax::ImporterRun.find(importer_run_id).increment!(:processed_relationships) # rubocop:disable Rails/SkipsModelValidations | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,10 @@ class ImportFileSetJob < ApplicationJob | |
|
||
queue_as :import | ||
|
||
attr_reader :importer_run_id | ||
|
||
def perform(entry_id, importer_run_id) | ||
@importer_run_id = importer_run_id | ||
entry = Entry.find(entry_id) | ||
parent_identifier = entry.raw_metadata[entry.related_parents_raw_mapping]&.strip | ||
|
||
|
@@ -63,7 +66,8 @@ def check_parent_is_a_work!(parent_identifier) | |
end | ||
|
||
def find_parent_record(parent_identifier) | ||
@parent_record ||= find_record(parent_identifier) | ||
@parent_record ||= find_record(parent_identifier, importer_run_id) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I tried calling |
||
@parent_record = parent_record.last if parent_record.is_a? Array | ||
end | ||
end | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
find_record
now returns two values, but we don't need the entry here