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

pulibrary / orangelight / 0e37073d-109c-440c-949f-49d2aa86311b

18 Aug 2025 09:05PM UTC coverage: 0.482% (-94.9%) from 95.343%
0e37073d-109c-440c-949f-49d2aa86311b

push

circleci

web-flow
Replace per_page_options_for_select with custom component to avoid deprecation issue (#5186)

* Start creating new component to address deprecaton warning

* Replace per_page_options_for_select with custom component to avoid deprecation issue

Co-authored-by: Jane Sandberg <sandbergja@users.noreply.github.com>

---------

Co-authored-by: Ryan Jensen <rj1044@princeton.edu>
Co-authored-by: Jane Sandberg <sandbergja@users.noreply.github.com>

0 of 33 new or added lines in 1 file covered. (0.0%)

9374 existing lines in 213 files now uncovered.

47 of 9753 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
UNCOV
2
module Requests
×
UNCOV
3
  module Bibdata
×
4
    # for PUL Bibliographic Helpers
UNCOV
5
    extend ActiveSupport::Concern
×
6

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

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

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

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

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

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

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

UNCOV
46
    def build_pick_ups
×
UNCOV
47
      pick_up_locations = []
×
UNCOV
48
      Requests::BibdataService.delivery_locations.each_value do |pick_up|
×
UNCOV
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
×
UNCOV
50
      end
×
UNCOV
51
      sort_pick_ups(pick_up_locations)
×
UNCOV
52
    end
×
53

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

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

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

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

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

73
    # get the location contact email from thr delivery locations via the library code
UNCOV
74
    def get_location_contact_email(location_code)
×
UNCOV
75
      code = get_location_data(location_code)
×
UNCOV
76
      library_code = code[:library]["code"]
×
UNCOV
77
      return I18n.t('requests.on_shelf.email') if library_code == "firestone"
×
UNCOV
78
      delivery_location = Requests::BibdataService.delivery_locations.select { |_key, value| value[:library][:code] == library_code }
×
UNCOV
79
      delivery_location.values.first[:contact_email]
×
UNCOV
80
    end
×
UNCOV
81
  end
×
UNCOV
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