Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions app/models/normalize_primo_record.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
8 changes: 4 additions & 4 deletions test/models/normalize_primo_record_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down