Skip to content

Commit

Permalink
Merge pull request #1024 from sul-dlss/uuid
Browse files Browse the repository at this point in the history
Add the FOLIO item uuid to item_display_struct
  • Loading branch information
jcoyne authored Jul 27, 2023
2 parents 21b4efc + 9b61e22 commit 5f25e9b
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 7 deletions.
5 changes: 0 additions & 5 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -153,11 +153,6 @@ Metrics/MethodLength:
Metrics/ModuleLength:
Max: 293

# Offense count: 2
# Configuration parameters: CountKeywordArgs, MaxOptionalParameters.
Metrics/ParameterLists:
Max: 9

# Offense count: 22
# Configuration parameters: AllowedMethods, AllowedPatterns.
Metrics/PerceivedComplexity:
Expand Down
2 changes: 2 additions & 0 deletions lib/folio_record.rb
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ def sirsi_holdings
current_location ||= folio_status_to_location(item['status'])

SirsiHolding.new(
id: item['id'],
call_number: [item.dig('callNumber', 'callNumber'), item['volume'], item['enumeration'], item['chronology']].compact.join(' '),
current_location: (current_location unless current_location == home_location_code),
home_location: home_location_code,
Expand All @@ -115,6 +116,7 @@ def bound_with_holdings
_current_library, current_location = LocationsMap.for(parent_item.dig('location', 'temporaryLocation', 'code'))
current_location ||= folio_status_to_location(parent_item['status'])
SirsiHolding.new(
id: parent_item['id'],
call_number: holding['callNumber'],
scheme: call_number_type_map(holding.dig('callNumberType', 'name')),
tag: {},
Expand Down
7 changes: 5 additions & 2 deletions lib/sirsi_holding.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,12 @@ class SirsiHolding
TECHSHADOW TECH-UNIQ WEST-7B SUPERSEDE WITHDRAWN].freeze
TEMP_CALLNUM_PREFIX = 'XX'.freeze

attr_reader :current_location, :home_location, :library, :scheme, :type, :barcode, :public_note, :tag
attr_reader :id, :current_location, :home_location, :library, :scheme, :type, :barcode, :public_note, :tag

def initialize(tag: nil, call_number: '', current_location: '', home_location: '', library: '', scheme: '', type: '',
# rubocop:disable Metrics/ParameterLists
def initialize(id: nil, tag: nil, call_number: '', current_location: '', home_location: '', library: '', scheme: '', type: '',
barcode: '', public_note: '')
@id = id
@call_number = call_number
@current_location = current_location
@home_location = home_location
Expand All @@ -35,6 +37,7 @@ def initialize(tag: nil, call_number: '', current_location: '', home_location: '
@tag = tag
@public_note = public_note
end
# rubocop:enable Metrics/ParameterLists

def call_number
@call_number_obj ||= CallNumber.new(normalize_call_number(@call_number))
Expand Down
1 change: 1 addition & 0 deletions lib/traject/config/sirsi_config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2375,6 +2375,7 @@ def holdings(record, context)
end

accumulator << {
id: holding.id,
barcode: holding.barcode,
library: holding.library,
home_location: holding.home_location,
Expand Down
6 changes: 6 additions & 0 deletions spec/integration/folio_config_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,12 @@
end

it { expect(result['item_display'].find { |h| h.match?(/CHECKEDOUT/) }).to be_present }

it 'includes the item UUID in the item_display_struct field' do
expect(result['item_display_struct'].map { |x| JSON.parse(x) }).to match_array([
hash_including('id' => '5362817d-f2df-503c-aa20-b2287c64ae25')
])
end
end

context 'item status is in-transit' do
Expand Down
2 changes: 2 additions & 0 deletions spec/lib/traject/config/callnum_facet_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

require 'sirsi_holding'

# rubocop:disable Metrics/ParameterLists
def record_with_999(call_number:, scheme:, indexer:, home_location: 'STACKS', library: 'GREEN', type: '')
indexer.map_record(
MARC::Record.new.tap do |r|
Expand All @@ -21,6 +22,7 @@ def record_with_999(call_number:, scheme:, indexer:, home_location: 'STACKS', li
end
)
end
# rubocop:enable Metrics/ParameterLists

RSpec.describe 'Call Number Facet' do
subject(:result) { indexer.map_record(record) }
Expand Down

0 comments on commit 5f25e9b

Please sign in to comment.