Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#2528] Don't include genres in Primary Source facet if only part of the word matches #2529

Merged
merged 1 commit into from
Oct 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion marc_to_solr/lib/genre.rb
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def genres_from_autobiography

def genre_term_indicates_primary_source?(genre)
normalized_genre = genre.downcase.strip.delete_suffix('.')
primary_source_genres.any? { |primary_source_genre| normalized_genre.include? primary_source_genre }
primary_source_genres.any? { |primary_source_genre| normalized_genre.match?(/(^|\W)#{primary_source_genre}($|\W)/) }
end

def biography?
Expand Down
10 changes: 10 additions & 0 deletions spec/marc_to_solr/lib/genre_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,16 @@
expect(genres).to include('Primary source')
end
end
context 'when the 650 subfield x has Computer network resources' do
let(:genres) do
g650 = { "650" => { "ind1" => " ", "ind2" => "0", "subfields" => [{ "a" => "Dating (Social customs)" }, { "x" => "Computer network resources." }] } }
sample_marc = MARC::Record.new_from_hash('fields' => [g650])
described_class.new(sample_marc).to_a
end
it 'does not include Primary Source in the list of genres' do
expect(genres).not_to include('Primary source')
end
end
context 'when the 650 subfield a is Biography' do
let(:genres) do
g650 = { "650" => { "ind1" => " ", "ind2" => "0", "subfields" => [{ "a" => "Biography" }] } }
Expand Down