• 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/requests/aeon_url.rb
1
# frozen_string_literal: true
2
module Requests
×
3
  # Create a URL that creates an aeon request
4
  class AeonUrl
×
5
    # @param document [SolrDocument]
6
    # @param holding [Hash]
7
    # @param item [Requests::Item]
8
    def initialize(document:, holding: nil, item: nil)
×
9
      @document = document
×
10
      @holding = holding.values.first if holding
×
11
      @item = item if item
×
12
    end
×
13

14
    def to_s
×
15
      aeon_url = Requests.config[:aeon_base]
×
16
      aeon_connector = "?Action=10&Form=30&"
×
17
      @compiled_string ||= "#{aeon_url}#{aeon_connector}#{query_string}"
×
18
    end
×
19

20
    private
×
21

22
      attr_reader :document
×
23

24
      def query_string
×
25
        "#{ctx_with_item_info.kev}&#{aeon_basic_params.to_query}"
×
26
      end
×
27

28
      def ctx_with_item_info
×
29
        ctx = @document.to_ctx
×
30
        if item.present?
×
31
          ctx.referent.set_metadata('iteminfo5', item['id']&.to_s)
×
32
          if item.enum_value.present?
×
33
            ctx.referent.set_metadata('volume', item.enum_value)
×
34
            ctx.referent.set_metadata('issue', item[:chron_display]) if item[:chron_display].present?
×
35
          else
×
36
            ctx.referent.set_metadata('volume', holding['location_has']&.first)
×
37
            ctx.referent.set_metadata('issue', nil)
×
38
          end
×
39
        end
×
40
        ctx
×
41
      end
×
42

43
      def aeon_basic_params
×
44
        {
×
45
          ReferenceNumber: @document[:id],
×
46
          CallNumber: holding['call_number'],
×
47
          Site: site,
×
48
          Location: shelf_location_code,
×
49
          SubLocation: sub_location,
×
50
          ItemInfo1: document['access_restrictions_note_display']&.first || I18n.t("requests.aeon.access_statement"),
×
51
          ItemNumber: item&.barcode,
×
52
          'rft.aucorp': document['pub_citation_display']&.first
×
53
        }.compact
×
54
      end
×
55

56
      def holding
×
57
        @holding ||= @document.holdings_all_display.values.first
×
58
      end
×
59

60
      def item
×
61
        @item ||= item_from_holding || item_from_document || Item.new({})
×
62
      end
×
63

64
      def item_from_holding
×
65
        item_hash = holding&.fetch('items', nil)&.first
×
66
        Item.new(item_hash.with_indifferent_access) if item_hash
×
67
      end
×
68

69
      def item_from_document
×
70
        item_hash = @document.holdings_all_display.values.first&.fetch('items', nil)&.first
×
71
        Item.new(item_hash.with_indifferent_access) if item_hash
×
72
      end
×
73

74
      def at_marquand?
×
75
        holding_location&.dig('library', 'code') == 'marquand'
×
76
      end
×
77

78
      def at_mudd?
×
79
        holding_location&.dig('library', 'code') == 'mudd' || thesis?
×
80
      end
×
81

82
      def holding_location
×
83
        ::Bibdata.holding_locations.fetch(shelf_location_code, nil)
×
84
      end
×
85

86
      def shelf_location_code
×
87
        holding&.fetch('location_code', nil)
×
88
      end
×
89

90
      def sub_location
×
91
        holding&.fetch('sub_location', nil)&.first
×
92
      end
×
93

94
      def thesis?
×
95
        @document.holdings_all_display&.keys&.first == "thesis"
×
96
      end
×
97

98
      def site
×
99
        return 'MUDD' if at_mudd?
×
100
        return 'MARQ' if at_marquand?
×
101
        'FIRE'
×
102
      end
×
103
  end
×
104
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