From 932dc2deb9e0562b8564cc1c29c86082824aeb69 Mon Sep 17 00:00:00 2001 From: Banu Kutlu Date: Wed, 17 Jun 2020 14:39:48 -0400 Subject: [PATCH 1/2] access facet uniq fix --- lib/marc_access_facet_processor.rb | 2 +- spec/fixtures/access_uniq.mrc | 1 + spec/lib/traject/access_facet_spec.rb | 5 +++++ 3 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 spec/fixtures/access_uniq.mrc diff --git a/lib/marc_access_facet_processor.rb b/lib/marc_access_facet_processor.rb index 8d0d3d98..61ceab96 100644 --- a/lib/marc_access_facet_processor.rb +++ b/lib/marc_access_facet_processor.rb @@ -26,7 +26,7 @@ def extract_access_data(record, context) end access << 'Online' if context.output_hash&.dig('ht_id_ssim') - access.compact.uniq + access = access.compact.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' From c10b0299f9e8ffbd6294360eeb66ef72defd1c2b Mon Sep 17 00:00:00 2001 From: Banu Kutlu Date: Wed, 17 Jun 2020 14:41:13 -0400 Subject: [PATCH 2/2] amend --- lib/marc_access_facet_processor.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/marc_access_facet_processor.rb b/lib/marc_access_facet_processor.rb index 61ceab96..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 = access.compact.uniq + access.compact! + access.uniq! access.delete 'On Order' if not_only_on_order? access access end