Skip to content

Commit

Permalink
πŸ› Fix #work_identifier_search_field logic (#891)
Browse files Browse the repository at this point in the history
* πŸ› Fix #work_identifier_search_field logic

The chaining logic for was grabbing the first letter of a single
search_field value; instead of grabbing the first value in the
'search_field' object.

To fix the problem, we cast the value of `search_field` into an array
and then grab the first array element.

Related to:

- #890

* 🧹 Appease rubocop
  • Loading branch information
jeremyf authored Dec 11, 2023
1 parent 8ff43fa commit 19102ad
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions app/parsers/bulkrax/application_parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def work_identifier
# defaults to work_identifier value + "_sim"
# @see #work_identifier
def work_identifier_search_field
@work_identifier_search_field ||= get_field_mapping_hash_for('source_identifier')&.values&.first&.[]('search_field')&.first&.to_s || "#{work_identifier}_sim"
@work_identifier_search_field ||= Array.wrap(get_field_mapping_hash_for('source_identifier')&.values&.first&.[]('search_field'))&.first&.to_s || "#{work_identifier}_sim"
end

# @return [String]
Expand All @@ -102,7 +102,7 @@ def related_parents_raw_mapping
# @return [String]
# @see #related_parents_field_mapping
def related_parents_parsed_mapping
@related_parents_parsed_mapping ||= (get_field_mapping_hash_for('related_parents_field_mapping')&.keys&.first || 'parents')
@related_parents_parsed_mapping ||= get_field_mapping_hash_for('related_parents_field_mapping')&.keys&.first || 'parents'
end

# @return [String, NilClass]
Expand All @@ -114,7 +114,7 @@ def related_children_raw_mapping
# @return [String]
# @see #related_children_raw_mapping
def related_children_parsed_mapping
@related_children_parsed_mapping ||= (get_field_mapping_hash_for('related_children_field_mapping')&.keys&.first || 'children')
@related_children_parsed_mapping ||= get_field_mapping_hash_for('related_children_field_mapping')&.keys&.first || 'children'
end

# @api private
Expand Down

0 comments on commit 19102ad

Please sign in to comment.