Skip to content
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

Strip subfield 0 data that starts with (SIRSI) #990

Merged
merged 1 commit into from
Jul 19, 2023
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 lib/folio_record.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@ def marc_record
@marc_record ||= begin
record ||= MARC::Record.new_from_hash(stripped_marc_json || instance_derived_marc_record)

record.fields.each do |field|
next unless field.respond_to? :subfields

field.subfields.delete_if { |subfield| subfield.code == '0' && subfield.value.start_with?('(SIRSI)') }
end

# Copy FOLIO Holdings electronic access data to an 856 (used by Lane)
# overwriting any existing 856 fields (to avoid having to reconcile/merge data)
eholdings = holdings.flat_map { |h| h['electronicAccess'] }
Expand Down
27 changes: 27 additions & 0 deletions spec/lib/folio_record_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,33 @@
it 'preserves non-junk tags' do
expect(folio_record.marc_record['001']).to have_attributes(tag: '001', value: 'a14154194')
end

context 'with subfield 0 data that used to be in the subfield =' do
let(:record) do
{
'instance' => {
'id' => '0e050e3f-b160-5f5d-9fdb-2d49305fbb0d'
},
'holdings' => [],
'source_record' => [{
'fields' => [
{ '264' => {
'subfields' => [
{ '0' => '(SIRSI)blah' },
{ '0' => 'http://example.com' }
]
} }
]
}]
}
end

it 'strips only that migrated data' do
expect(folio_record.marc_record['264'].subfields).to match_array([
have_attributes(code: '0', value: 'http://example.com')
])
end
end
end

describe 'the 590 field' do
Expand Down