From eaad70034e64687f1be6df73a16ecdd1180ce930 Mon Sep 17 00:00:00 2001 From: Justin Coyne Date: Wed, 5 Jul 2023 15:54:06 -0500 Subject: [PATCH] Map SUL/SDR location to SUL/INTERNET for parity --- lib/locations_map.rb | 11 +++++++---- spec/integration/compare_sirsi_and_folio_spec.rb | 4 ++-- .../lib/folio/eresource_holdings_builder_spec.rb | 16 ++++++++++++++++ 3 files changed, 25 insertions(+), 6 deletions(-) diff --git a/lib/locations_map.rb b/lib/locations_map.rb index c205ba2bd..5aca360b2 100644 --- a/lib/locations_map.rb +++ b/lib/locations_map.rb @@ -2,6 +2,7 @@ require 'csv' +# This starts with the location.tsv file provided by libsys. We make any modifications to that data here. class LocationsMap include Singleton @@ -16,14 +17,16 @@ def data def load_map CSV.parse(File.read(File.join(__dir__, 'translation_maps', 'locations.tsv')), - col_sep: "\t").each_with_object({}) do |row, hash| - library_code = row[1] + col_sep: "\t").each_with_object({}) do |(home_location, library_code, folio_code), hash| library_code = { 'LANE' => 'LANE-MED' }.fetch(library_code, library_code) # SAL3's CDL/ONORDER/INPROCESS locations are all mapped so SAL3-STACKS - next if row[2] == 'SAL3-STACKS' && row[0] != 'STACKS' + next if folio_code == 'SAL3-STACKS' && home_location != 'STACKS' - hash[row[2]] ||= [library_code, row[0]] + # Recode SUL-SDR to have "INTERNET" be it's home_locaion + home_location = 'INTERNET' if home_location == 'SDR' + + hash[folio_code] ||= [library_code, home_location] end end end diff --git a/spec/integration/compare_sirsi_and_folio_spec.rb b/spec/integration/compare_sirsi_and_folio_spec.rb index 777bd3a15..f4548fedb 100644 --- a/spec/integration/compare_sirsi_and_folio_spec.rb +++ b/spec/integration/compare_sirsi_and_folio_spec.rb @@ -163,7 +163,8 @@ 'a10690790', # ezproxy prefix 'a81622', # missing status 'a14644326', # in-process status - 'a3118108' # missing status + 'a3118108', # missing status + 'a10146027' # SUL/SDR instead of SUL/INTERNET ].each do |catkey| context "catkey #{catkey}" do let(:catkey) { catkey } @@ -179,7 +180,6 @@ 'a515836', # funky call-number problems 'a6634796', # missing call number in item_display 'a1553634', # migration error holdings - 'a10146027', # SUL/SDR instead of SUL/INTERNET 'a12264341', # extra electronic items 'a9335111', # missing bound-withs 'a14461522', # ??? diff --git a/spec/lib/folio/eresource_holdings_builder_spec.rb b/spec/lib/folio/eresource_holdings_builder_spec.rb index 8ff5e82fb..54d6687c0 100644 --- a/spec/lib/folio/eresource_holdings_builder_spec.rb +++ b/spec/lib/folio/eresource_holdings_builder_spec.rb @@ -92,4 +92,20 @@ it { expect(holdings).to be_empty } end + + context 'the holding location is SUL-SDR' do + let(:items_and_holdings) do + { 'items' => [], + 'holdings' => + [{ 'location' => + { 'permanentLocation' => + { 'code' => 'SUL-SDR' }, + 'effectiveLocation' => + { 'code' => 'SUL-SDR' } }, + 'suppressFromDiscovery' => false, + 'id' => '81a56270-e8dd-5759-8083-5cc96cdf0045', + 'holdingsStatements' => [] }] } + end + it { expect(holdings.first.home_location).to eq 'INTERNET' } + end end