diff --git a/app/models/normalize_primo_record.rb b/app/models/normalize_primo_record.rb index cb15beb0..cb1331dd 100644 --- a/app/models/normalize_primo_record.rb +++ b/app/models/normalize_primo_record.rb @@ -184,6 +184,9 @@ def doi if @record['pnx']['addata']['doi'].length > 1 Sentry.set_tags('mitlib.recordId': identifier || 'empty record id') Sentry.capture_message('Multiple DOIs found in one record') + + # Exit method to avoid ambiguous LibKey lookups. + return end @record['pnx']['addata']['doi'].first @@ -195,6 +198,9 @@ def pmid if @record['pnx']['addata']['pmid'].length > 1 Sentry.set_tags('mitlib.recordId': identifier || 'empty record id') Sentry.capture_message('Multiple PMIDs found in one record') + + # Exit method to avoid ambiguous LibKey lookups. + return end @record['pnx']['addata']['pmid'].first diff --git a/test/models/normalize_primo_record_test.rb b/test/models/normalize_primo_record_test.rb index c234d5ae..1fb4fd99 100644 --- a/test/models/normalize_primo_record_test.rb +++ b/test/models/normalize_primo_record_test.rb @@ -142,13 +142,13 @@ def cdi_record assert_nil normalized[:doi] end - test 'multiple dois normalize to the first one' do + test 'multiple dois are ignored' do temp_record = full_record temp_record['pnx']['addata']['doi'] = %w[three two one] normalized = NormalizePrimoRecord.new(temp_record, 'test').normalize - assert_equal normalized[:doi], 'three' + assert_nil normalized[:doi] end test 'normalizes pmid' do @@ -161,13 +161,13 @@ def cdi_record assert_nil normalized[:pmid] end - test 'multiple pmids normalize to the first one' do + test 'multiple pmids are ignored' do temp_record = full_record temp_record['pnx']['addata']['pmid'] = %w[three two one] normalized = NormalizePrimoRecord.new(temp_record, 'test').normalize - assert_equal normalized[:pmid], 'three' + assert_nil normalized[:pmid] end test 'normalizes summary' do