• 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/requests/submissions/recap.rb
1
# frozen_string_literal: true
UNCOV
2
require 'faraday'
×
3

UNCOV
4
module Requests::Submissions
×
UNCOV
5
  class Recap < Service
×
UNCOV
6
    include Requests::Scsb
×
7

UNCOV
8
    def initialize(submission, service_type: 'recap')
×
UNCOV
9
      super
×
UNCOV
10
    end
×
11

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

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

UNCOV
26
    private
×
27

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

UNCOV
47
      def handle_hold_for_item(item)
×
UNCOV
48
        return if submission.partner_item?(item) || submission.edd?(item)
×
49

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

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