From 92623568811a9c865f0dcd05b928c1124bdfdf82 Mon Sep 17 00:00:00 2001 From: jazairi <16103405+jazairi@users.noreply.github.com> Date: Thu, 13 Aug 2026 09:51:19 -0700 Subject: [PATCH 1/2] Add full-text options to relevant Alma records Why these changes are being introduced: Certain catalog records include an electronic holding that is not included in the `links` `object of the PNX metadata. For these records, Primo displays a 'Full-text options' section with the e-resource link, but SML displays nothing because it only checks `links` for this information. Relevant ticket(s): - [USE-663](https://mitlibraries.atlassian.net/browse/USE-663) How this addresses that need: This adds 'Full-text options' to a result's `links` object, provided the result meets the following conditions: - pnx['links'] is nil - pnx['deliveryCategory'] includes Alma-E The 'Full-text options' link resolves to the corresponding section of the Primo record. Side effects of this change: This decision infers that all Primo records that meet the two conditions above will have a 'Full-text options' section. If this assumption is incorrect, it will result in a confusing user experience. --- app/models/normalize_primo_record.rb | 11 ++++- test/models/normalize_primo_record_test.rb | 54 ++++++++++++++++++++++ 2 files changed, 63 insertions(+), 2 deletions(-) diff --git a/app/models/normalize_primo_record.rb b/app/models/normalize_primo_record.rb index e277451e..090e84c1 100644 --- a/app/models/normalize_primo_record.rb +++ b/app/models/normalize_primo_record.rb @@ -131,6 +131,13 @@ def links end end + # Add Full-text options if pnx['links'] is nil and record has Alma-E (electronic availability) + if @record['pnx']['links'].nil? && + @record['delivery']['deliveryCategory']&.include?('Alma-E') && + record_link.present? + links << { 'url' => "#{record_link}#nui.getit.service_viewit", 'kind' => 'Full-text options' } + end + # Return links if we found any links.any? ? links : [] end @@ -327,8 +334,8 @@ def score # FRBR Group check based on: # https://knowledge.exlibrisgroup.com/Primo/Knowledge_Articles/Primo_Search_API_-_how_to_get_FRBR_Group_members_after_a_search def frbrized? - return unless @record['pnx']['facets'] - return unless @record['pnx']['facets']['frbrtype'] + return false unless @record['pnx']['facets'] + return false unless @record['pnx']['facets']['frbrtype'] @record['pnx']['facets']['frbrtype'].join == '5' end diff --git a/test/models/normalize_primo_record_test.rb b/test/models/normalize_primo_record_test.rb index 96f42e79..090c22a0 100644 --- a/test/models/normalize_primo_record_test.rb +++ b/test/models/normalize_primo_record_test.rb @@ -458,6 +458,60 @@ def cdi_record assert_not normalized[:dedup_record] end + test 'includes Full-text options link when pnx[links] is nil and both Alma-P and Alma-E present' do + record = alma_record.deep_dup + + # Ensure no direct links + record['pnx']['links'] = nil + + # Add delivery category with both physical and electronic + record['delivery']['deliveryCategory'] = %w[Alma-P Alma-E] + normalized = NormalizePrimoRecord.new(record, 'test').normalize + full_text_link = normalized[:links].find { |link| link['kind'] == 'Full-text options' } + assert_not_nil full_text_link + assert_match %r{/discovery/fulldisplay\?}, full_text_link['url'] + assert_match(/#nui\.getit\.service_viewit$/, full_text_link['url']) + end + + test 'excludes Full-text options link when pnx[links] is present' do + record = full_record.deep_dup + + # Add delivery category with electronic + record['delivery']['deliveryCategory'] = %w[Alma-E] + normalized = NormalizePrimoRecord.new(record, 'test').normalize + full_text_link = normalized[:links].find { |link| link['kind'] == 'Full-text options' } + assert_nil full_text_link + end + + test 'excludes Full-text options link when only Alma-P present' do + record = alma_record.deep_dup + record['pnx']['links'] = nil + record['delivery']['deliveryCategory'] = ['Alma-P'] + normalized = NormalizePrimoRecord.new(record, 'test').normalize + full_text_link = normalized[:links].find { |link| link['kind'] == 'Full-text options' } + assert_nil full_text_link + end + + test 'includes Full-text options link when only Alma-E present' do + record = alma_record.deep_dup + record['pnx']['links'] = nil + record['delivery']['deliveryCategory'] = ['Alma-E'] + normalized = NormalizePrimoRecord.new(record, 'test').normalize + full_text_link = normalized[:links].find { |link| link['kind'] == 'Full-text options' } + assert_not_nil full_text_link + assert_match %r{/discovery/fulldisplay\?}, full_text_link['url'] + assert_match(/#nui\.getit\.service_viewit$/, full_text_link['url']) + end + + test 'excludes Full-text options link when no delivery category present' do + record = alma_record.deep_dup + record['pnx']['links'] = nil + record['delivery']['deliveryCategory'] = nil + normalized = NormalizePrimoRecord.new(record, 'test').normalize + full_text_link = normalized[:links].find { |link| link['kind'] == 'Full-text options' } + assert_nil full_text_link + end + test 'dedup_url requires both frbrized and alma_record conditions' do # CDI record that is frbrized - should return nil normalizer = NormalizePrimoRecord.new(cdi_record, 'test') From 65426fe1b417c18dbdad830a6a2651ffc754b73b Mon Sep 17 00:00:00 2001 From: Isra Jazairi Date: Thu, 13 Aug 2026 18:37:24 -0400 Subject: [PATCH 2/2] Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --- app/models/normalize_primo_record.rb | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/app/models/normalize_primo_record.rb b/app/models/normalize_primo_record.rb index 090e84c1..7def2380 100644 --- a/app/models/normalize_primo_record.rb +++ b/app/models/normalize_primo_record.rb @@ -132,10 +132,11 @@ def links end # Add Full-text options if pnx['links'] is nil and record has Alma-E (electronic availability) - if @record['pnx']['links'].nil? && - @record['delivery']['deliveryCategory']&.include?('Alma-E') && - record_link.present? - links << { 'url' => "#{record_link}#nui.getit.service_viewit", 'kind' => 'Full-text options' } + full_record_link = record_link + if @record.dig('pnx', 'links').nil? && + @record.dig('delivery', 'deliveryCategory')&.include?('Alma-E') && + full_record_link.present? + links << { 'url' => "#{full_record_link}#nui.getit.service_viewit", 'kind' => 'Full-text options' } end # Return links if we found any