Skip to content

Commit

Permalink
solr document handles non loc_id subject ids
Browse files Browse the repository at this point in the history
  • Loading branch information
niquerio committed May 21, 2024
1 parent fd1dac0 commit 32c3b5a
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 9 deletions.
4 changes: 2 additions & 2 deletions lib/authority_browse/solr_document/authority_graph.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ def term
first[:label]
end

# Library of Congress ID
# Library of Congress ID if the id is a valid one
#
# @return [String]
def loc_id
first[:id]
first[:id] if first[:id].match?("loc.gov")
end

# @return [Integer]
Expand Down
3 changes: 0 additions & 3 deletions spec/authority_browse/names_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@
expect(file_contents).to eq([
{
id: "first\u001fname",
loc_id: "id1",
browse_field: "name",
term: "First",
count: 1,
Expand All @@ -71,15 +70,13 @@
}.to_json + "\n",
{
id: "second\u001fname",
loc_id: "id2",
browse_field: "name",
term: "Second",
count: 2,
date_of_index: Date.today.strftime("%Y-%m-%d") + "T00:00:00Z"
}.to_json + "\n",
{
id: "third\u001fname",
loc_id: "id3",
browse_field: "name",
term: "Third",
count: 3,
Expand Down
6 changes: 5 additions & 1 deletion spec/authority_browse/solr_document/subjects_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,13 @@
end
end
context "#loc_id" do
it "returns the loc_id" do
it "returns the loc_id when the id is a loc id" do
expect(subject.loc_id).to eq(counterpoint_id)
end
it "returns nil when it's not" do
@subject[0][:id] = "9912351598"
expect(subject.loc_id).to be_nil
end
end
context "#term" do
it "has the expected term" do
Expand Down
3 changes: 0 additions & 3 deletions spec/authority_browse/subjects_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@
expect(file_contents).to eq([
{
id: "first\u001fsubject",
loc_id: "id1",
browse_field: "subject",
term: "First",
count: 1,
Expand All @@ -88,15 +87,13 @@
}.to_json + "\n",
{
id: "second\u001fsubject",
loc_id: "id2",
browse_field: "subject",
term: "Second",
count: 2,
date_of_index: Date.today.strftime("%Y-%m-%d") + "T00:00:00Z"
}.to_json + "\n",
{
id: "third\u001fsubject",
loc_id: "id3",
browse_field: "subject",
term: "Third",
count: 3,
Expand Down

0 comments on commit 32c3b5a

Please sign in to comment.