• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

pulibrary / orangelight / 00dbc10b-d747-4ad7-b211-7b26d753abbb

14 Aug 2025 01:25PM UTC coverage: 0.483% (-94.9%) from 95.343%
00dbc10b-d747-4ad7-b211-7b26d753abbb

push

circleci

web-flow
Merge pull request #5181 from pulibrary/dependabot/bundler/activestorage-7.2.2.2

Bump activestorage from 7.2.2.1 to 7.2.2.2

47 of 9721 relevant lines covered (0.48%)

0.01 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/app/models/concerns/requests/bibdata.rb
1
# frozen_string_literal: true
2
module Requests
×
3
  module Bibdata
×
4
    # for PUL Bibliographic Helpers
5
    extend ActiveSupport::Concern
×
6

7
    def solr_doc(system_id)
×
8
      response = Faraday.get "#{Requests.config[:pulsearch_base]}/catalog/#{system_id}/raw"
×
9
      parse_response(response)
×
10
    end
×
11

12
    def items_by_bib(system_id)
×
13
      response = bibdata_conn.get "/availability?id=#{system_id}"
×
14
      parse_response(response)
×
15
    end
×
16

17
    def items_by_mfhd(system_id, mfhd_id)
×
18
      response = bibdata_conn.get "/bibliographic/#{system_id}/holdings/#{mfhd_id}/availability.json"
×
19
      parse_response(response)
×
20
    end
×
21

22
    def get_location_data(location_code)
×
23
      response = bibdata_conn.get "/locations/holding_locations/#{location_code}.json"
×
24
      parse_response(response)
×
25
    end
×
26

27
    def bibdata_conn
×
28
      conn = Faraday.new(url: Requests.config[:bibdata_base]) do |faraday|
×
29
        faraday.request  :url_encoded # form-encode POST params
×
30
        # faraday.response :logger                  # log requests to STDOUT
31
        faraday.response :logger unless Rails.env.test?
×
32
        faraday.adapter  Faraday.default_adapter # make requests with Net::HTTP
×
33
      end
×
34
      conn
×
35
    end
×
36

37
    def parse_response(response)
×
38
      parsed = response.status == 200 ? parse_json(response.body) : {}
×
39
      parsed.class == Hash ? parsed.with_indifferent_access : parsed
×
40
    end
×
41

42
    def parse_json(data)
×
43
      JSON.parse(data)
×
44
    end
×
45

46
    def build_pick_ups
×
47
      pick_up_locations = []
×
48
      Requests::BibdataService.delivery_locations.each_value do |pick_up|
×
49
        pick_up_locations << { label: pick_up["label"], gfa_pickup: pick_up["gfa_pickup"], pick_up_location_code: pick_up["library"]["code"] || 'firestone', staff_only: pick_up["staff_only"] } if pick_up["pickup_location"] == true
×
50
      end
×
51
      sort_pick_ups(pick_up_locations)
×
52
    end
×
53

54
    ## Accepts an array of location hashes and sorts them according to our quirks
55
    def sort_pick_ups(locs)
×
56
      # staff only locations go at the bottom of the list and Firestone to the top
57

58
      public_locs = locs.select { |loc| loc[:staff_only] == false }
×
59
      public_locs.sort_by! { |loc| loc[:label] }
×
60

61
      firestone = public_locs.find { |loc| loc[:label] == "Firestone Library" }
×
62
      public_locs.insert(0, public_locs.delete_at(public_locs.index(firestone))) unless firestone.nil?
×
63

64
      staff_locs = locs.select { |loc| loc[:staff_only] == true }
×
65
      staff_locs.sort_by! { |loc| loc[:label] }
×
66

67
      staff_locs.each do |loc|
×
68
        loc[:label] = loc[:label] + " (Staff Only)"
×
69
      end
×
70
      public_locs + staff_locs
×
71
    end
×
72

73
    # get the location contact email from thr delivery locations via the library code
74
    def get_location_contact_email(location_code)
×
75
      code = get_location_data(location_code)
×
76
      library_code = code[:library]["code"]
×
77
      return I18n.t('requests.on_shelf.email') if library_code == "firestone"
×
78
      delivery_location = Requests::BibdataService.delivery_locations.select { |_key, value| value[:library][:code] == library_code }
×
79
      delivery_location.values.first[:contact_email]
×
80
    end
×
81
  end
×
82
end
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc