Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2024 06 07 exceptions #183

Merged
merged 4 commits into from
Jun 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,23 @@ def value(data, request = nil)
extra_headings = []

rows = bib_record.elec_holdings.map do |holding|
[
{href: holding.link, text: link_text || holding.link_text},
{text: [holding.description, holding.note].compact.join(' - ')}
]
# TODO: Use Spectrum::Presenters::ElectronicItem.for(holding) instead
if holding.respond_to?(:description)
[
{href: holding.link, text: link_text || holding.link_text},
{text: [holding.description, holding.note].compact.join(' - ')}
]
elsif holding.respond_to?(:delivery_description)
[
{href: holding.link, text: link_text || holding.link_text},
{text: [holding.delivery_description, holding.note].compact.join(' - ')}
]
else
[
{href: holding.link, text: link_text || holding.link_text},
{text: holding.note}
]
end
end

return nil if rows.nil? || rows.empty?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class LibKey

def self.for_data(config, type, data)
return nil unless data
url = config['host'] + "/public/v1/libraries/#{config['library_id']}/articles/#{type}/#{data}"
url = config['host'] + "/public/v1/libraries/#{config['library_id']}/articles/#{type}/#{CGI.escape(data)}"
headers = {'Authorization' => "Bearer #{config['key']}"}
response = HTTParty.get(url, headers: headers)
return nil unless response.code == 200
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,23 @@ class Response
attr_accessor :info, :highlights, :docs, :timelog, :facets

def self.for_json(json)
return self.new(
info: Info.for_json(json['info']),
highlights: Highlights.for_json(json['highlights']),
docs: Docs.for_json(json['docs'], json['info']['first'].to_i),
timelog: Timelog.for_json(json['timelog']),
facets: Facets.for_json(json['facets'])
)
begin
return self.new(
info: Info.for_json(json['info']),
highlights: Highlights.for_json(json['highlights']),
docs: Docs.for_json(json['docs'], json['info']['first'].to_i),
timelog: Timelog.for_json(json['timelog']),
facets: Facets.for_json(json['facets'])
)
rescue MultiXml::ParseError => e
return self.new(
info: Info.for_json(nil),
highlights: Highlights.for_json(nil),
docs: Docs.for_json([], 0),
timelog: Timelog.for_json(nil),
facets: Facets.for_json([]),
)
end
end

def with_libkey(config)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def cited_title
:missing?, :known_off_shelf?, :open_stacks?, :checked_out?, :reopened?,
:flint?, :in_labeling?, :in_acq?, :reservable_library?,
:in_international_studies_acquisitions_technical_services?,
:recallable?].each do |name|
:recallable?, :can_scan?].each do |name|
define_method(name) do
false
end
Expand Down
Loading