Skip to content

Commit

Permalink
Thesis Department index (#473)
Browse files Browse the repository at this point in the history
* Adds thesis_dept display field to traject extracts.  Modifies which theses are ok to grab

* Fixes and adds test

* Refactor
  • Loading branch information
ajkiessl authored May 22, 2023
1 parent 3c022c9 commit 363cc7d
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
1 change: 1 addition & 0 deletions config/traject.rb
Original file line number Diff line number Diff line change
Expand Up @@ -574,6 +574,7 @@
end

# 699a Thesis Department
to_field 'thesis_dept_display_ssm', extract_marc('699a'), trim_punctuation, include_psu_theses_only
to_field 'thesis_dept_facet', extract_marc('699a'), trim_punctuation, include_psu_theses_only

# 773 - "Part Of"
Expand Down
2 changes: 1 addition & 1 deletion lib/psulib_traject/macros.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

NOT_FULLTEXT = /addendum|appendices|appendix|appendixes|cover|excerpt|executive summary|index/i.freeze
PSU_THESIS_CODE = /THESIS-B|THESIS-D|THESIS-M/.freeze
PSU_THESIS_CODE = /THESIS-D|THESIS-M/.freeze
ESTIMATE_TOLERANCE = 15
MIN_YEAR = 500
MAX_YEAR = Time.new.year + 6
Expand Down
19 changes: 13 additions & 6 deletions spec/integration/macros_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@
let(:thesis_dept_699) do
{ '699' => { 'subfields' => [{ 'a' => 'Acoustics.' }] } }
end
let(:result) { indexer.map_record(MARC::Record.new_from_hash('fields' => [thesis_dept_699, code_949], 'leader' => leader)) }

context 'when a record has no 949t fields' do
let(:result) { indexer.map_record(MARC::Record.new_from_hash('fields' => [thesis_dept_699], 'leader' => leader)) }
Expand All @@ -213,22 +214,28 @@

context 'when a record does not have a PSU thesis code' do
let(:code_949) do
{ '949' => { 'subfields' => [{ 'a' => 'Thesis 2011mOrr,A', 't' => 'THESIS-A' }] } }
{ '949' => { 'subfields' => [{ 'a' => 'Thesis 2011mOrr,A', 't' => 'THESIS-B' }] } }
end

let(:result) { indexer.map_record(MARC::Record.new_from_hash('fields' => [thesis_dept_699, code_949], 'leader' => leader)) }

it 'does not index the theses department data' do
expect(result['thesis_dept_facet']).to be_nil
end
end

context 'when a record does have a PSU thesis code' do
context 'when thesis code is THESIS-D' do
let(:code_949) do
{ '949' => { 'subfields' => [{ 'a' => 'Thesis 2011mOrr,A', 't' => 'THESIS-B' }] } }
{ '949' => { 'subfields' => [{ 'a' => 'Thesis 2011mOrr,A', 't' => 'THESIS-D' }] } }
end

it 'indexes the theses department data' do
expect(result['thesis_dept_facet']).to eq ['Acoustics']
end
end

let(:result) { indexer.map_record(MARC::Record.new_from_hash('fields' => [thesis_dept_699, code_949], 'leader' => leader)) }
context 'when thesis code is THESIS-M' do
let(:code_949) do
{ '949' => { 'subfields' => [{ 'a' => 'Thesis 2011mOrr,A', 't' => 'THESIS-M' }] } }
end

it 'indexes the theses department data' do
expect(result['thesis_dept_facet']).to eq ['Acoustics']
Expand Down

0 comments on commit 363cc7d

Please sign in to comment.