Skip to content

Commit

Permalink
Fixed the electronic holding campuses
Browse files Browse the repository at this point in the history
campuses works the same way as institution codes
  • Loading branch information
niquerio committed Apr 1, 2024
1 parent fa43fb2 commit bc4ecda
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 18 deletions.
21 changes: 11 additions & 10 deletions umich_catalog_indexing/lib/umich_traject/electronic_holding.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,24 @@ def library
end

def link
code_map = {
"ann_arbor" => "UMAA",
"flint" => "UMFL"
}
URI::DEFAULT_PARSER.escape(@e56["u"].sub("openurl", "openurl-#{code_map[link_campus]}"))
code = (_alma_campuses.count == 1 && _alma_campuses.first == "UMFL") ? "UMFL" : "UMAA"
URI::DEFAULT_PARSER.escape(@e56["u"].sub("openurl", "openurl-#{code}"))
end

def link_text
"Available online"
end

def link_campus
def campuses
inst_code_map = {
"UMAA" => "ann_arbor",
"UMFL" => "flint"
}
# return flint when it's the only campus
if _alma_campuses.count == 1 && _alma_campuses.first == "UMFL"
"flint"
if _alma_campuses.empty?
inst_code_map.values
else
"ann_arbor"
_alma_campuses.map { |code| inst_code_map[code] }
end
end

Expand Down Expand Up @@ -86,7 +87,7 @@ def to_h
"library",
"link",
"link_text",
"link_campus",
"campuses",
"interface_name",
"collection_name",
"authentication_note",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,22 +71,22 @@ def get_record(path)
expect(subject.institution_codes).to eq(["MIFLIC"])
end
end
context "#link_campus" do
it "shows ann_arbor when no c code" do
expect(subject.link_campus).to eq("ann_arbor")
context "#campuses" do
it "shows both ann_arbor and flint when no c code" do
expect(subject.campuses).to contain_exactly("ann_arbor", "flint")
end
it "shows ann_arbor when both UMAA and UMFL are present" do
it "shows both ann_arbor and flint when both UMAA and UMFL are present" do
ann_arbor_campus
flint_campus
expect(subject.link_campus).to eq("ann_arbor")
expect(subject.campuses).to contain_exactly("ann_arbor", "flint")
end
it "shows ann_arbor when c code is only UMAA" do
ann_arbor_campus
expect(subject.link_campus).to eq("ann_arbor")
expect(subject.campuses).to contain_exactly("ann_arbor")
end
it "shows flint when c code is only UMFL" do
flint_campus
expect(subject.link_campus).to eq("flint")
expect(subject.campuses).to contain_exactly("flint")
end
end
context "#interface_name" do
Expand Down Expand Up @@ -137,7 +137,7 @@ def get_record(path)
"library" => s.library,
"link" => s.link,
"link_text" => s.link_text,
"link_campus" => s.link_campus,
"campuses" => s.campuses,
"interface_name" => s.interface_name,
"collection_name" => s.collection_name,
"authentication_note" => s.authentication_note,
Expand Down

0 comments on commit bc4ecda

Please sign in to comment.