Skip to content

Commit

Permalink
Report on bib entries missing info
Browse files Browse the repository at this point in the history
  • Loading branch information
xuanxu committed Mar 6, 2024
1 parent e184c72 commit 8b04406
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
10 changes: 4 additions & 6 deletions app/lib/doi_checker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,17 @@ def check_dois
# If there's no DOI present, check Crossref to see if we can find a candidate DOI for this entry.
elsif entry.has_field?('title')
candidate_doi = crossref_lookup(entry.title.value)
truncated_title = entry.title.to_s[0,50]
truncated_title += "..." if truncated_title.length < entry.title.to_s.length
if candidate_doi == "CROSSREF-ERROR"
truncated_title = entry.title.to_s[0,50]
truncated_title += "..." if truncated_title.length < entry.title.to_s.length
doi_summary[:missing].push("Errored finding suggestions for \"#{truncated_title}\", please try later")
elsif candidate_doi
doi_summary[:missing].push("#{candidate_doi} may be a valid DOI for title: #{entry.title}")
doi_summary[:missing].push("#{candidate_doi} may be a valid DOI for title: #{truncated_title}")
else
doi_summary[:missing].push("No DOI given, and none found for title: #{truncated_title}")
end
else
truncated_entry = entry.to_s[0,50]
truncated_entry += "..." if truncated_entry.length entry.to_s.length
doi_summary[:missing].push("No DOI or title given for entry #{truncated_entry}")
doi_summary[:missing].push("Entry without DOI or title found")
end
end
end
Expand Down
4 changes: 2 additions & 2 deletions spec/doi_checker_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@

doi_summary = doi_checker.check_dois
expect(doi_summary[:ok]).to be_empty
expect(doi_summary[invalid]).to be_empty
expect(doi_summary[:missing][0]).to eq("No DOI or title given for entry #{entry.to_s}")
expect(doi_summary[:invalid]).to be_empty
expect(doi_summary[:missing][0]).to eq("Entry without DOI or title found")
end
end

Expand Down

0 comments on commit 8b04406

Please sign in to comment.