Skip to content

Commit

Permalink
Merge pull request #3667 from sul-dlss/folio-location-code
Browse files Browse the repository at this point in the history
Pull over location code mapping from the indexer, which handled order…
  • Loading branch information
cbeer authored Nov 1, 2023
2 parents 907b9a6 + a977844 commit b118573
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 4 deletions.
15 changes: 11 additions & 4 deletions app/services/folio/locations_map.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,17 @@ def data
end

def reverse_data
@reverse_data ||= data.each_with_object({}) do |(symphony_library_code, locations), hash|
locations.each do |symphony_location_code, folio_location_code|
hash[folio_location_code] = [symphony_library_code, symphony_location_code]
end
@reverse_data ||= CSV.parse(file_contents, col_sep: "\t").each_with_object({}) do |(home_location, library_code, folio_code), hash|
# SAL3's CDL/ONORDER/INPROCESS locations are all mapped so SAL3-STACKS
next if folio_code == 'SAL3-STACKS' && home_location != 'STACKS'

library_code = 'LANE-MED' if library_code == 'LANE'
library_code = 'MEDIA-MTXT' if library_code == 'MEDIA-CENTER'

# 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

Expand Down
17 changes: 17 additions & 0 deletions spec/services/folio/locations_map_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
require 'rails_helper'

RSpec.describe Folio::LocationsMap do
describe '.for' do
it 'returns the Folio location code for a given Symphony library and location' do
expect(Folio::LocationsMap.for(library_code: 'GREEN', location_code: 'STACKS')).to eq('GRE-STACKS')
end
end

describe '.symphony_code_for' do
it 'returns the Symphony location code for a given Folio location' do
expect(Folio::LocationsMap.symphony_code_for(location_code: 'GRE-STACKS')).to eq(['GREEN', 'STACKS'])
expect(Folio::LocationsMap.symphony_code_for(location_code: 'SAL3-STACKS')).to eq(['SAL3', 'STACKS'])
expect(Folio::LocationsMap.symphony_code_for(location_code: 'LANE-LAN')).to eq(['LANE-MED', 'LANE-LAN'])
end
end
end

0 comments on commit b118573

Please sign in to comment.