Skip to content

Commit

Permalink
feat: NOP-71 Update "Names" facet to aggregate values from many fields (
Browse files Browse the repository at this point in the history
#971)

* feat: NOP-71 Update "Names" facet to aggregate values from many fields

* NOP-71 - added spec

* NOP-71 - rubocop

* NOP-71 - rubocop

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
  • Loading branch information
kethlinmil and github-actions[bot] authored Feb 14, 2025
1 parent 1572fd8 commit 745b5c5
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 20 deletions.
10 changes: 1 addition & 9 deletions app/importers/californica_mapper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -85,15 +85,7 @@ class CalifornicaMapper < Darlingtonia::HashMapper
"Personal or Corporate Name.subject",
"Subject.corporateName",
"Subject.personalName",
"Subject name",
"Host",
"Name.host",
"Musician",
"Name.musician",
"Name.printer",
"Printer",
"Name.researcher",
"Researcher"],
"Subject name"],
normalized_date: "Date.normalized",
note: ["Note"],
note_admin: ["AdminNote", "Description.adminnote", "Note.admin"],
Expand Down
11 changes: 11 additions & 0 deletions app/indexers/work_indexer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class WorkIndexer < Hyrax::WorkIndexer
def generate_solr_document
super.tap do |solr_doc|
solr_doc['combined_subject_ssim'] = combined_subject
solr_doc['combined_names_ssim'] = combined_names
add_dates(solr_doc)
solr_doc['geographic_coordinates_ssim'] = coordinates
solr_doc['human_readable_iiif_text_direction_ssi'] = human_readable_iiif_text_direction
Expand Down Expand Up @@ -66,6 +67,16 @@ def combined_subject
object.named_subject.to_a + object.subject.to_a + object.subject_topic.to_a + object.subject_geographic.to_a + object.subject_temporal.to_a
end

def combined_names
%w[
architect arranger artist author calligrapher cartographer collector commentator composer
creator director editor engraver host illuminator illustrator interviewee interviewer librettist
lyricist musician photographer printer printmaker producer recipient researcher rubricator scribe translator
].sum do |field_name|
object.send(field_name).to_a
end
end

def coordinates
return unless object.latitude.first && object.longitude.first
[object.latitude.first, object.longitude.first].join(', ')
Expand Down
10 changes: 8 additions & 2 deletions spec/indexers/work_indexer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,27 @@

let(:indexer) { described_class.new(work) }

describe 'combined_subject' do
describe 'combined_subject and combined_names' do
let(:attributes) do
{
ark: 'ark:/123/456',
subject: ['Subject 1', 'Subject 2'],
named_subject: ['Named Subject'],
subject_topic: ['Subject Topic'],
subject_geographic: ['Subject Geographic']
subject_geographic: ['Subject Geographic'],
architect: ['John Smith'],
artist: ['Jane Doe']
}
end

it 'combines the relevant subject fields' do
expect(solr_document['combined_subject_ssim']).to contain_exactly('Subject 1', 'Subject 2', 'Named Subject', 'Subject Topic', 'Subject Geographic')
end

it 'combines the relevant names fields' do
expect(solr_document['combined_names_ssim']).to contain_exactly('John Smith', 'Jane Doe')
end

context 'When subject fields are missing' do
let(:attributes) do
{
Expand Down
9 changes: 0 additions & 9 deletions spec/uploaders/csv_manifest_validator_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -327,15 +327,6 @@
"Name.printer",
"Researcher",
"Name.researcher",
# adds these twice because they are also part of named_subject
"Host",
"Name.host",
"Musician",
"Name.musician",
"Printer",
"Name.printer",
"Researcher",
"Name.researcher",
"Rights.statementLocal",
"Related Records",
"Edition",
Expand Down

0 comments on commit 745b5c5

Please sign in to comment.