Skip to content

Commit

Permalink
Merge pull request #1479 from sul-dlss/leading-a
Browse files Browse the repository at this point in the history
Strip the leading a from catkeys in collection fields
  • Loading branch information
jcoyne authored Jun 27, 2024
2 parents 6563624 + 03c6539 commit d2e7f91
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/traject/config/folio_config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2313,7 +2313,7 @@ def accumulate_summary_struct_fields(matching_fields, tag, label, marc, accumula
end.select do |(type, _druid, _id, _title)|
type == 'collection'
end.map do |(_type, druid, id, _title)|
id.empty? ? druid : id
id.empty? ? druid : id.sub(/^a(\d+)$/, '\1')
end)
end
end
Expand Down Expand Up @@ -2343,7 +2343,7 @@ def accumulate_summary_struct_fields(matching_fields, tag, label, marc, accumula
end.select do |(type, _druid, _id, _title)|
type == 'set'
end.map do |(_type, druid, id, _title)|
id.empty? ? druid : id
id.empty? ? druid : id.sub(/^a(\d+)$/, '\1')
end)
end
end
Expand Down
38 changes: 38 additions & 0 deletions spec/lib/traject/config/managed_purl_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,25 @@
expect(select_by_id('ManagedAnd2UnmanagedPurlCollection')[field]).to contain_exactly 'sirsi', 'folio'
expect(select_by_id('NoManagedPurlItem')[field]).to contain_exactly 'sirsi', 'folio'
end

context 'with an 856 prefixed with a' do
let(:record) do
MARC::Record.new.tap do |r|
r.leader = '01737cam a2200445Ka 4500'
r.append(MARC::ControlField.new('001', 'a4820195'))
r.append(MARC::DataField.new('856', ' ', ' ',
MARC::Subfield.new('x', 'SDR-PURL'),
MARC::Subfield.new('x', 'item'),
MARC::Subfield.new('x', 'collection:yg867hg1375:a9615156:Francis E. Stafford photographs, 1909-1933')))
end
end

subject(:result) { indexer.map_record(marc_to_folio(record)) }

it 'strips the a from the catkey' do
expect(result[field]).to include '9615156'
end
end
end

describe 'collection_with_title' do
Expand Down Expand Up @@ -92,6 +111,25 @@
expect(select_by_id('ManagedAnd2UnmanagedPurlCollection')[field]).to eq nil
expect(select_by_id('NoManagedPurlItem')[field]).to eq nil
end

context 'with an 856 prefixed with a' do
let(:record) do
MARC::Record.new.tap do |r|
r.leader = '01737cam a2200445Ka 4500'
r.append(MARC::ControlField.new('001', 'a4820195'))
r.append(MARC::DataField.new('856', ' ', ' ',
MARC::Subfield.new('x', 'SDR-PURL'),
MARC::Subfield.new('x', 'item'),
MARC::Subfield.new('x', 'set:aa000bb1111:123456789:Test Set, 1963-2015')))
end
end

subject(:result) { indexer.map_record(marc_to_folio(record)) }

it 'strips the a from the catkey' do
expect(result[field]).to include '123456789'
end
end
end

describe 'set_with_title' do
Expand Down

0 comments on commit d2e7f91

Please sign in to comment.