From 9429da05aa43511e7fe0f0211185fcb17062b396 Mon Sep 17 00:00:00 2001 From: Adam Wead Date: Mon, 9 Aug 2021 12:12:54 -0400 Subject: [PATCH] Return explicit shelf key types in struct The keymap_struct needs to indicate which key is the forward and reverse key. This will allow to us build the correct list when retrieving them from Solr in the catalog. --- config/traject.rb | 2 +- lib/psulib_traject/call_number.rb | 5 +++-- spec/lib/psulib_traject/call_number_spec.rb | 5 +++-- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/config/traject.rb b/config/traject.rb index fd8c2e16..acd4dc7d 100644 --- a/config/traject.rb +++ b/config/traject.rb @@ -294,7 +294,7 @@ context.add_output('call_number_lc_ssm', *call_numbers.map(&:value)) context.add_output('forward_lc_shelfkey', *call_numbers.map(&:forward_shelfkey)) context.add_output('reverse_lc_shelfkey', *call_numbers.map(&:reverse_shelfkey)) - context.add_output('keymap_struct', *call_numbers.map(&:keymap).reduce(&:merge).to_json) + context.add_output('keymap_struct', *call_numbers.map(&:keymap).to_json) end # Material Characteristics diff --git a/lib/psulib_traject/call_number.rb b/lib/psulib_traject/call_number.rb index 8eb7c536..9dae4001 100644 --- a/lib/psulib_traject/call_number.rb +++ b/lib/psulib_traject/call_number.rb @@ -34,8 +34,9 @@ def reverse_shelfkey def keymap { - forward_shelfkey => value, - reverse_shelfkey => value + 'call_number' => value, + 'forward_key' => forward_shelfkey, + 'reverse_key' => reverse_shelfkey } end diff --git a/spec/lib/psulib_traject/call_number_spec.rb b/spec/lib/psulib_traject/call_number_spec.rb index 2bd03b03..dd6da97b 100644 --- a/spec/lib/psulib_traject/call_number_spec.rb +++ b/spec/lib/psulib_traject/call_number_spec.rb @@ -93,8 +93,9 @@ its(:keymap) do is_expected.to eq( { - 'AB.0123.C456.2000' => 'AB123 .C456 2000', - 'PO.ZYXW.NVUT.XZZZ~' => 'AB123 .C456 2000' + 'call_number' => 'AB123 .C456 2000', + 'forward_key' => 'AB.0123.C456.2000', + 'reverse_key' => 'PO.ZYXW.NVUT.XZZZ~' } ) end