From 642d0799f2fb336fd4e28f511ae70ff6219a0214 Mon Sep 17 00:00:00 2001 From: Jeremy Prevost Date: Mon, 3 Nov 2025 08:30:13 -0500 Subject: [PATCH 01/17] Update Primo normalization to use symbols --- app/models/normalize_primo_record.rb | 54 +++++----- app/views/search/_result_primo.html.erb | 18 ++-- test/controllers/search_controller_test.rb | 10 +- test/models/normalize_primo_record_test.rb | 110 ++++++++++---------- test/models/normalize_primo_results_test.rb | 4 +- 5 files changed, 98 insertions(+), 98 deletions(-) diff --git a/app/models/normalize_primo_record.rb b/app/models/normalize_primo_record.rb index d967eb33..cac88518 100644 --- a/app/models/normalize_primo_record.rb +++ b/app/models/normalize_primo_record.rb @@ -8,25 +8,25 @@ def initialize(record, query) def normalize { # Core fields - 'title' => title, - 'creators' => creators, - 'source' => source, - 'year' => year, - 'format' => format, - 'links' => links, - 'citation' => citation, - 'identifier' => record_id, - 'summary' => summary, - 'publisher' => publisher, - 'location' => best_location, - 'subjects' => subjects, + title:, + creators:, + source:, + year:, + format:, + links:, + citation:, + identifier:, + summary:, + publisher:, + location:, + subjects:, # Primo-specific fields - 'container' => container_title, - 'numbering' => numbering, - 'chapter_numbering' => chapter_numbering, - 'thumbnail' => thumbnail, - 'availability' => best_availability, - 'other_availability' => other_availability? + container:, + numbering:, + chapter_numbering:, + thumbnail:, + availability:, + other_availability: } end @@ -115,7 +115,7 @@ def citation end end - def container_title + def container return unless @record['pnx']['addata'] if @record['pnx']['addata']['jtitle'].present? @@ -125,7 +125,7 @@ def container_title end end - def record_id + def identifier return unless @record['pnx']['control']['recordid'] @record['pnx']['control']['recordid'].join @@ -224,7 +224,7 @@ def openurl if openurl_server == record_openurl_server construct_primo_openurl else - Rails.logger.warn "Alma openurl server mismatch. Expected #{openurl_server}, but received #{record_openurl_server}. (record ID: #{record_id})" + Rails.logger.warn "Alma openurl server mismatch. Expected #{openurl_server}, but received #{record_openurl_server}. (record ID: #{identifier})" @record['delivery']['almaOpenurl'] end end @@ -265,7 +265,7 @@ def publisher @record['pnx']['addata']['pub'].first end - def best_location + def location return unless @record['delivery'] return unless @record['delivery']['bestlocation'] @@ -279,13 +279,13 @@ def subjects @record['pnx']['display']['subject'] end - def best_availability - return unless best_location + def availability + return unless location @record['delivery']['bestlocation']['availabilityStatus'] end - def other_availability? + def other_availability return unless @record['delivery']['bestlocation'] return unless @record['delivery']['holding'] @@ -302,9 +302,9 @@ def frbrized? end def alma_record? - return false unless record_id + return false unless identifier - record_id.start_with?('alma') + identifier.start_with?('alma') end def dedup_url diff --git a/app/views/search/_result_primo.html.erb b/app/views/search/_result_primo.html.erb index bd4c5bba..89a9cbb7 100644 --- a/app/views/search/_result_primo.html.erb +++ b/app/views/search/_result_primo.html.erb @@ -2,22 +2,22 @@

Title: - <% if result['links']&.find { |link| link['kind'] == 'full record' } %> - <%= link_to(result['title'], result['links'].find { |link| link['kind'] == 'full record' }['url']) %> + <% if result[:links]&.find { |link| link['kind'] == 'full record' } %> + <%= link_to(result[:title], result[:links].find { |link| link['kind'] == 'full record' }['url']) %> <% else %> - <%= result['title'] %> + <%= result[:title] %> <% end %>

- <%= result['format'] %> - <%= result['year'] %> + <%= result[:format] %> + <%= result[:year] %>

- <% if result['creators'].present? %> + <% if result[:creators].present? %> Contributors: