diff --git a/app/assets/stylesheets/partials/_results.scss b/app/assets/stylesheets/partials/_results.scss index cb0b6cb3..675b9fc8 100644 --- a/app/assets/stylesheets/partials/_results.scss +++ b/app/assets/stylesheets/partials/_results.scss @@ -123,6 +123,7 @@ overflow: hidden; display: -webkit-box; -webkit-line-clamp: 3; + line-clamp: 3; -webkit-box-orient: vertical; text-overflow: ellipsis; } @@ -404,4 +405,4 @@ @media (max-width: $bp-screen-md) { flex-direction: column; } -} \ No newline at end of file +} diff --git a/app/helpers/record_helper.rb b/app/helpers/record_helper.rb index 9a42bcd7..31ee0fcd 100644 --- a/app/helpers/record_helper.rb +++ b/app/helpers/record_helper.rb @@ -7,7 +7,7 @@ def date_parse(date) date end - def date_range(range) + def geo_date_range(range) return unless range.present? "#{date_parse(range['gte'])} to #{date_parse(range['lte'])}" diff --git a/app/models/normalize_primo_record.rb b/app/models/normalize_primo_record.rb index ce576e1e..b6198bae 100644 --- a/app/models/normalize_primo_record.rb +++ b/app/models/normalize_primo_record.rb @@ -115,17 +115,9 @@ def links end def citation - return unless @record['pnx']['addata'] + return unless @record['pnx']['display'] - if @record['pnx']['addata']['volume'].present? - if @record['pnx']['addata']['issue'].present? - "volume #{@record['pnx']['addata']['volume'].join} issue #{@record['pnx']['addata']['issue'].join}" - else - "volume #{@record['pnx']['addata']['volume'].join}" - end - elsif @record['pnx']['addata']['date'].present? && @record['pnx']['addata']['pages'].present? - "#{@record['pnx']['addata']['date'].join}, pp. #{@record['pnx']['addata']['pages'].join}" - end + @record['pnx']['display']['ispartof']&.first end def container diff --git a/app/models/normalize_timdex_record.rb b/app/models/normalize_timdex_record.rb index fe691f70..79025186 100644 --- a/app/models/normalize_timdex_record.rb +++ b/app/models/normalize_timdex_record.rb @@ -24,6 +24,7 @@ def normalize subjects:, # TIMDEX-specific fields content_type:, + date_range:, dates:, contributors:, highlight:, @@ -34,7 +35,26 @@ def normalize private def title - @record['title'] || 'Unknown title' + title = @record['title'] || 'Unknown title' + + # The collection identifier is important for ASpace records so we append it to the title + return title unless source == 'MIT ArchivesSpace' + + title += " (#{aspace_collection(@record['identifiers'])})" + end + + def aspace_collection(identifiers) + relevant_ids = identifiers.map { |id| id['value'] if id['kind'] == 'Collection Identifier' }.compact + + # In the highly unlikely event that there is more than one collection identifier, there's something weird going + # on with the record and we should look into it. + if relevant_ids.count > 1 + Sentry.set_tags('mitlib.recordId': identifier || 'empty record id') + Sentry.set_tags('mitlib.collection_ids': relevant_ids.join('; ')) + Sentry.capture_message('Multiple Collection IDs found in ASpace record') + end + + relevant_ids.first end def creators @@ -104,7 +124,7 @@ def links end def citation - @record['citation'] || nil + @record['citation'] end def summary @@ -130,7 +150,7 @@ def location def subjects return [] unless @record['subjects'] - @record['subjects'].map { |subject| subject['value'] } + @record['subjects'].flat_map { |subject| subject['value'] } end def identifier @@ -146,6 +166,25 @@ def dates @record['dates'] end + def date_range + return unless @record['dates'] + + # Some records have creation or publication dates that are ranges. Extract those here. + relevant_dates = @record['dates'].select do |date| + %w[creation publication].include?(date['kind']) && date['range'].present? + end + + # If the record has no creation or publication date, stop here. + return if relevant_dates.empty? + + # If the record *does* have more than one creation/pub date, just take the first one. Note: ASpace records often + # have more than one. Sometimes they are duplicates, sometimes they are different. For now we will just take the + # first. + relevant_date = relevant_dates.first + + "#{relevant_date['range']['gte']}-#{relevant_date['range']['lte']}" + end + def contributors @record['contributors'] end diff --git a/app/models/timdex_search.rb b/app/models/timdex_search.rb index 2af3aaf2..34a59778 100644 --- a/app/models/timdex_search.rb +++ b/app/models/timdex_search.rb @@ -50,6 +50,10 @@ class TimdexSearch < TimdexBase hits records { timdexRecordId + identifiers { + kind + value + } title source contentType @@ -61,6 +65,10 @@ class TimdexSearch < TimdexBase dates { kind value + range { + gte + lte + } } links { kind @@ -84,6 +92,11 @@ class TimdexSearch < TimdexBase } sourceLink summary + subjects { + kind + value + } + citation } aggregations { accessToFiles { diff --git a/app/views/record/_record.html.erb b/app/views/record/_record.html.erb index ce24af22..6b3aa88e 100644 --- a/app/views/record/_record.html.erb +++ b/app/views/record/_record.html.erb @@ -127,7 +127,7 @@