Skip to content

Commit

Permalink
Merge pull request #1446 from projectblacklight/remove-and
Browse files Browse the repository at this point in the history
Allow for multiple extents
  • Loading branch information
lfarrell authored Dec 11, 2023
2 parents 02c950a + ea34ddc commit 41f14f8
Show file tree
Hide file tree
Showing 10 changed files with 66 additions and 23 deletions.
4 changes: 3 additions & 1 deletion app/components/arclight/group_component.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
</div>
<% end %>
<h3><%= helpers.link_to_document document %></h3>
<%= tag.span(document.extent, class: 'al-document-extent badge') if document.extent %>
<% document.extent.each do |extent| %>
<%= tag.span extent, class: 'al-document-extent badge' unless compact? %>
<% end %>
<%= render Arclight::IndexMetadataFieldComponent.with_collection(presenter.field_presenters.select { |field| !compact? || field.field_config.compact }) %>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
<header class="documentHeader row" data-document-id="<%= @document.id %>">
<h3 class="index_title document-title-heading col">
<%= helpers.link_to_document @document, counter: @counter %>
<%= tag.span @document.extent, class: 'al-document-extent badge' if @document.extent && !compact? %>
<% @document.extent.each do |extent| %>
<%= tag.span extent, class: 'al-document-extent badge' unless compact? %>
<% end %>
<%= tag.span class: 'al-document-container text-muted ml-auto' do %>
<%= @document.containers.join(', ') %>
<% end if @document.containers.present? %>
Expand Down
2 changes: 1 addition & 1 deletion app/models/concerns/arclight/solr_document.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ module SolrDocument
attribute :parent_labels, :array, 'parent_unittitles_ssm'
attribute :parent_levels, :array, 'parent_levels_ssm'
attribute :unitid, :string, 'unitid_ssm'
attribute :extent, :string, 'extent_ssm'
attribute :extent, :array, 'extent_ssm'
attribute :abstract, :string, 'abstract_html_tesm'
attribute :scope, :string, 'scopecontent_html_tesm'
attribute :creator, :string, 'creator_ssm'
Expand Down
17 changes: 15 additions & 2 deletions lib/arclight/traject/ead2_component_config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,21 @@
accumulator.concat settings[:root].output_hash['normalized_title_ssm']
end

to_field 'extent_ssm', extract_xpath('./did/physdesc/extent')
to_field 'extent_tesim', extract_xpath('./did/physdesc/extent')
to_field 'extent_ssm' do |record, accumulator|
physdescs = record.xpath('./did/physdesc')
extents_per_physdesc = physdescs.map do |physdesc|
extents = physdesc.xpath('./extent').map { |e| e.text.strip }
# Join extents within the same physdesc with an empty string
extents.join(' ')
end

# Add each physdesc separately to the accumulator
accumulator.concat(extents_per_physdesc)
end

to_field 'extent_tesim' do |_record, accumulator, context|
accumulator.concat context.output_hash['extent_ssm'] || []
end

to_field 'creator_ssm', extract_xpath('./did/origination')
to_field 'creator_ssim', extract_xpath('./did/origination')
Expand Down
18 changes: 16 additions & 2 deletions lib/arclight/traject/ead2_config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,22 @@
end
end

to_field 'extent_ssm', extract_xpath('/ead/archdesc/did/physdesc/extent')
to_field 'extent_tesim', extract_xpath('/ead/archdesc/did/physdesc/extent')
to_field 'extent_ssm' do |record, accumulator|
physdescs = record.xpath('/ead/archdesc/did/physdesc')
extents_per_physdesc = physdescs.map do |physdesc|
extents = physdesc.xpath('./extent').map { |e| e.text.strip }
# Join extents within the same physdesc with an empty string
extents.join(' ')
end

# Add each physdesc separately to the accumulator
accumulator.concat(extents_per_physdesc)
end

to_field 'extent_tesim' do |_record, accumulator, context|
accumulator.concat context.output_hash['extent_ssm'] || []
end

to_field 'genreform_ssim', extract_xpath('/ead/archdesc/controlaccess/genreform')

to_field 'date_range_isim', extract_xpath('/ead/archdesc/did/unitdate/@normal', to_text: false) do |_record, accumulator|
Expand Down
12 changes: 6 additions & 6 deletions spec/features/grouped_results_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@

RSpec.describe 'Grouped search results' do
it 'displays collection group information' do
visit search_catalog_path q: 'alpha omega', group: 'true'
visit search_catalog_path q: 'student life', group: 'true'
within '.al-grouped-title-bar' do
expect(page).to have_css 'h3 a', text: /Alpha/
expect(page).to have_css '.al-document-abstract-or-scope', text: /founded in 1902/
expect(page).to have_css '.badge', text: '15.0 linear feet (36 boxes + oversize folder)'
expect(page).to have_css 'h3 a', text: /photograph album/
expect(page).to have_css '.al-document-abstract-or-scope', text: /track meets/
expect(page).to have_css('.al-document-extent.badge', count: 3)
end
within '.grouped-documents' do
expect(page).to have_css 'article', count: 3
expect(page).to have_css 'article', count: 1
end
end

Expand Down Expand Up @@ -52,7 +52,7 @@
within '.al-grouped-title-bar' do
expect(page).to have_css 'h3 a', text: /Alpha/
expect(page).not_to have_css '.al-document-abstract-or-scope', text: /founded in 1902/
expect(page).to have_css '.badge', text: '15.0 linear feet (36 boxes + oversize folder)'
expect(page).not_to have_css('.badge')
end
end
end
Expand Down
8 changes: 5 additions & 3 deletions spec/features/traject/ead2_indexing_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,10 @@ def components(result)
expect(result['places_ssim']).to equal_array_ignoring_whitespace ['Yosemite National Park (Calif.)']
end

it 'physdesc' do
expect(result['extent_ssm']).to equal_array_ignoring_whitespace ['1.25 Linear Feet (1 volume)', '1 document case', '16 DVDRs']
end

it 'has_online_content' do
expect(result['has_online_content_ssim']).to eq [true]
end
Expand Down Expand Up @@ -293,9 +297,7 @@ def components(result)

it 'extent at the collection level' do
%w[extent_ssm extent_tesim].each do |field|
expect(result[field]).to equal_array_ignoring_whitespace(
['15.0 linear feet (36 boxes + oversize folder)']
)
expect(result[field]).to equal_array_ignoring_whitespace(['15.0 linear feet (36 boxes + oversize folder)', '3 CDs'])
end
end

Expand Down
5 changes: 4 additions & 1 deletion spec/fixtures/ead/nlm/alphaomegaalpha.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,13 @@
<corpname source="ingest">Alpha Omega Alpha</corpname>
</origination>
<unitid>MS C 271</unitid>
<physdesc altrender="whole">
<physdesc altrender="part">
<extent altrender="materialtype spaceoccupied">15.0 linear feet (36 boxes + oversize
folder)</extent>
</physdesc>
<physdesc altrender="part">
<extent altrender="materialtype spaceoccupied">3 CDs</extent>
</physdesc>
<unitdate normal="1894/1992" type="inclusive">1894-1992</unitdate>
<langmaterial id="aspace_1cf405d4520ad390ab7b5532eab3ea00">Collection materials primarily in
<language langcode="eng">English.</language></langmaterial>
Expand Down
12 changes: 8 additions & 4 deletions spec/fixtures/ead/sul-spec/a0011.xml
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,16 @@
</corpname>
</origination>
<unitid>A0011</unitid>
<physdesc altrender="whole">
<extent altrender="materialtype spaceoccupied">1.25 Linear
Feet
</extent>
<physdesc altrender="part">
<extent altrender="materialtype spaceoccupied">1.25 Linear Feet</extent>
<extent altrender="carrier">(1 volume)</extent>
</physdesc>
<physdesc altrender="part">
<extent altrender="materialtype spaceoccupied">1 document case</extent>
</physdesc>
<physdesc altrender="part">
<extent altrender="materialtype spaceoccupied">16 DVDRs</extent>
</physdesc>
<unitdate normal="1900/1906" type="inclusive">circa 1900-1906
</unitdate>
</did>
Expand Down
7 changes: 5 additions & 2 deletions spec/models/arclight/document_downloads_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
id: 'abc123',
unitid_ssm: ['sample_unitid'],
userestrict_html_tesm: ['The Terms of the Collection'],
extent_ssm: ['42GB'], # This field does not typically hold file size, but for test purposes..
level_ssm: ['collection'],
ref_ssm: ['http://example.com/finding-aid.pdf'] # This field does not typically hold URLs, but for test purposes..
)
Expand Down Expand Up @@ -55,10 +54,14 @@
end

context 'when a size_accessor is provided for the size' do
before do
allow(document).to receive(:finding_aid_size).and_return('42GB')
end

let(:file_params) do
{
data: {
'size_accessor' => 'extent',
'size_accessor' => 'finding_aid_size',
'href' => 'http://example.com/finding-aid.pdf'
}
}
Expand Down

0 comments on commit 41f14f8

Please sign in to comment.