diff --git a/lib/marc_access_facet_processor.rb b/lib/marc_access_facet_processor.rb index 8d0d3d98..1b3619a3 100644 --- a/lib/marc_access_facet_processor.rb +++ b/lib/marc_access_facet_processor.rb @@ -26,7 +26,8 @@ def extract_access_data(record, context) end access << 'Online' if context.output_hash&.dig('ht_id_ssim') - access.compact.uniq + access.compact! + access.uniq! access.delete 'On Order' if not_only_on_order? access access end diff --git a/spec/fixtures/access_uniq.mrc b/spec/fixtures/access_uniq.mrc new file mode 100644 index 00000000..270f9605 --- /dev/null +++ b/spec/fixtures/access_uniq.mrc @@ -0,0 +1 @@ +008986789 00097 0010005000009490127000059490127001329490225002599490225004849490091007091234 aElectronic resourcewASISc1i4059691-2001lONLINEmONLINErYsYtONLINEu10/19/2007o.STAFF. 20071003 EEBO#2 STC1-59dedup aElectronic resourcewASISc1i4059691-2001lONLINEmONLINErYsYtONLINEu10/19/2007o.STAFF. 20071003 EEBO#2 STC1-59dedup aMicrofilm D18 reel.907:1wASISc1i000079527897d10/2/2009e7/22/2009lCATO-2mUP-ANNEXn1q1rYsYtMICROFORMu10/19/2007z8043o.STAFF. Upon return, route to cataloging. 7/21/09 smo.STAFF. 20071003 EEBO#2 STC1-59dedup aMicrofilm D18 reel.907:1wASISc1i000079527897d10/2/2009e7/22/2009lCATO-2mUP-ANNEXn1q1rYsYtMICROFORMu10/19/2007z8043o.STAFF. Upon return, route to cataloging. 7/21/09 smo.STAFF. 20071003 EEBO#2 STC1-59dedup aAQ14656449wLCc1i000080938682lON-ORDERmUP-PATrYsYtBOOKu1/10/2019o.STAFF. GOBI \ No newline at end of file diff --git a/spec/lib/traject/access_facet_spec.rb b/spec/lib/traject/access_facet_spec.rb index fad3609e..2a1da548 100644 --- a/spec/lib/traject/access_facet_spec.rb +++ b/spec/lib/traject/access_facet_spec.rb @@ -32,6 +32,11 @@ expect(result['access_facet']).to contain_exactly 'In the Library', 'Online' end + it 'produces a uniq set of access facet values' do + result = @indexer.map_record(MARC::Reader.new(File.join(fixture_path, 'access_uniq.mrc')).to_a.first) + expect(result['access_facet']).to contain_exactly 'Online', 'In the Library' + end + it 'produces Other when a record has a 949m library code that is not listed' do result = @indexer.map_record(MARC::Reader.new(File.join(fixture_path, 'access_other.mrc')).to_a.first) expect(result['access_facet']).to contain_exactly 'Other'