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

pulibrary / orangelight / 4c391e0e-519a-40cb-8ad3-354445f4ce03

12 Aug 2025 08:47PM UTC coverage: 85.348% (-10.0%) from 95.335%
4c391e0e-519a-40cb-8ad3-354445f4ce03

push

circleci

web-flow
[#5143] Use access restriction note as Aeon ItemInfo1 if available (#5173)

With this commit, if a user visits a record with an access
restrictions note and presses the Reading Room Request
button, they will get to an Aeon form with the 'Restrictions'
field pre-filled with the restriction note.

If the record does not have an access restrictions note,
the field will be pre-filled with 'Reading Room Access Only',
as it has been previously.

Closes #5143

5493 of 6436 relevant lines covered (85.35%)

251.82 hits per line

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

80.0
/app/models/requests/submissions/recap.rb
1
# frozen_string_literal: true
2
require 'faraday'
1✔
3

4
module Requests::Submissions
1✔
5
  class Recap < Service
1✔
6
    include Requests::Scsb
1✔
7

8
    def initialize(submission, service_type: 'recap')
1✔
9
      super
7✔
10
    end
11

12
    def handle
1✔
13
      items = submission.filter_items_by_service(service_type)
7✔
14
      items.each do |item|
7✔
15
        handle_item(item)
7✔
16
      end
17
    end
18

19
    def send_mail
1✔
20
      return if errors.present?
7✔
21
      hashed_submission = submission.to_h # Sidekiq will only accept a hash, not a Requests::Submission object
6✔
22
      Requests::RequestMailer.send("#{service_type}_email", hashed_submission).deliver_later unless ['recap_edd', 'recap'].include?(service_type)
6✔
23
      Requests::RequestMailer.send("#{service_type}_confirmation", hashed_submission).deliver_later
6✔
24
    end
25

26
    private
1✔
27

28
      def handle_item(item)
1✔
29
        params = scsb_param_mapping(submission.bib, submission.patron, item)
7✔
30
        response = scsb_request(params)
7✔
31
        if response.status != 200
7✔
32
          error_message = "Request failed because #{response.body}"
1✔
33
          @errors << { type: 'recap', bibid: params[:bibId], item: params[:itemBarcodes], user_name: submission.user_name, barcode: submission.user_barcode, error: error_message }
1✔
34
        else
35
          response = parse_scsb_response(response)
6✔
36
          if response[:success] == false
6✔
37
            @errors << { type: 'recap', bibid: params[:bibId], item: params[:itemBarcodes], user_name: submission.user_name, barcode: submission.user_barcode, error: response[:screenMessage] }
×
38
          else
39
            @sent << { bibid: params[:bibId], item: params[:itemBarcodes], user_name: submission.user_name, barcode: submission.user_barcode }
6✔
40
            handle_hold_for_item(item)
6✔
41
          end
42
        end
43
      rescue JSON::ParserError
44
        @errors << { type: 'recap', bibid: params[:bibId], item: params[:itemBarcodes], user_name: submission.user_name, barcode: submission.user_barcode, error: "Invalid response from the SCSB server: #{response.body}" }
×
45
      end
46

47
      def handle_hold_for_item(item)
1✔
48
        return if submission.partner_item?(item) || submission.edd?(item)
6✔
49

50
        hold = Requests::Submissions::HoldItem.new(@submission, service_type: "recap")
2✔
51
        hold.handle_item(item:)
2✔
52
        return if hold.errors.empty?
2✔
53
        hold.errors.map! do |error|
×
54
          reply_text = error["reply_text"]
×
55
          error.merge("reply_text" => "Recap request was successful, but creating the hold in Alma had an error: #{reply_text}")
×
56
        end
57
        service_errors = hold.error_hash
×
58
        send_error_email(service_errors, @submission)
×
59
      end
60

61
      # This has to be a utility function to prevent ActiveJob from trying to serialize too many objects
62
      # :reek:UtilityFunction
63
      def send_error_email(errors, submission)
1✔
64
        Requests::RequestMailer.send("service_error_email", errors, submission.to_h).deliver_later
×
65
      end
66
  end
67
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