Skip to content

Commit

Permalink
is able to identify HT items with no full text option
Browse files Browse the repository at this point in the history
  • Loading branch information
niquerio committed Apr 29, 2024
1 parent 4919331 commit 86db782
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
14 changes: 14 additions & 0 deletions umich_catalog_indexing/lib/jobs/zephir_processing/record.rb
Original file line number Diff line number Diff line change
@@ -1,14 +1,28 @@
require "traject/macros/marc21_semantics"
require "ht_traject/ht_macros"
module Jobs
module ZephirProcessing
class Record
attr_reader :raw
include Traject::Macros::Marc21Semantics
include HathiTrust::Traject::Macros
def initialize(raw)
@raw = raw
@record = MARC::Record.new_from_hash(JSON.parse(@raw))
end

# Does the record only contain in copyright materials? Restated:
# Does the record not have any public domain materials?
# return [Boolean]
def no_full_text?
has_at_least_one_full_text = @record.fields("974")
.map { |x| x["r"] } # get the rights subfield
.any? do |rights| # do any of the rights options match full text?
statusFromRights(rights) == "Full text"
end
!has_at_least_one_full_text
end

def is_umich?
# umich record is preferred record
return true if @record["HOL"]["c"] == "MIU"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,15 @@
expect(subject.has_oclc_num?(1111)).to eq(false)
end
end
context "#no_full_text?" do
it "returns true when there are no Full Text items associated with the record" do
expect(subject.no_full_text?).to eq(true)
end
it "returns false when there is at least one Full Text item associated with the record" do
@zephir_record["fields"][45]["974"]["subfields"][7]["r"] = "pdus"
expect(subject.no_full_text?).to eq(false)
end
end
context "#is_umich?" do
it "returns true when umich is the preffered record" do
@zephir_record["fields"][42]["HOL"]["subfields"][3]["c"] = "MIU"
Expand Down

0 comments on commit 86db782

Please sign in to comment.