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

pulibrary / bibdata / b3c4a532-5da0-46f8-9c20-20018605a028

21 Mar 2025 08:11PM UTC coverage: 42.257% (-49.9%) from 92.185%
b3c4a532-5da0-46f8-9c20-20018605a028

push

circleci

sandbergja
Move various gems from the default Gemfile group to a more appropriate group

1599 of 3784 relevant lines covered (42.26%)

2.56 hits per line

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

81.25
/app/controllers/barcode_controller.rb
1
class BarcodeController < ApplicationController
1✔
2
  include FormattingConcern
1✔
3

4
  # Client: This endpoint is used by the ReCAP inventory management system, LAS,
5
  #   to pull data from our ILS when items are accessioned
6
  def scsb
1✔
7
    barcode = params[:barcode]
7✔
8
    if valid_barcode?(barcode)
7✔
9
      adapter = AlmaAdapter.new
7✔
10
      item = adapter.item_by_barcode(barcode)
7✔
11
      mms_id = item['bib_data']['mms_id']
5✔
12
      record = adapter.get_bib_record(mms_id, show_suppressed: true)
5✔
13

14
      # If the bib record is not found, the returned record will be nil and the controller should return with a 404 status
15
      if record.nil?
5✔
16
        render plain: "Record #{mms_id} not found", status: :not_found
×
17
        return
×
18
      end
19
      holding = adapter.holding_by_id(mms_id:, holding_id: item.holding_data['holding_id'])
5✔
20
      records = if record.linked_record_ids.present?
4✔
21
                  adapter.get_bib_records(record.linked_record_ids)
1✔
22
                else
23
                  [record]
3✔
24
                end
25
      records.each do |bib_record|
4✔
26
        bib_record.enrich_with_item(item)
5✔
27
        bib_record.delete_conflicting_holding_data!
5✔
28
        bib_record.enrich_with_holding(holding, recap: true)
5✔
29
        bib_record.strip_non_numeric!
5✔
30
      end
31
      if records == []
4✔
32
        render plain: "Barcode #{barcode} not found.", status: :not_found
×
33
      else
34
        respond_to do |wants|
4✔
35
          wants.json  do
4✔
36
            json = MultiJson.dump(pass_records_through_xml_parser(records))
×
37
            render json:
×
38
          end
39
          wants.xml do
4✔
40
            xml = records_to_xml_string(records)
4✔
41
            render xml:
4✔
42
          end
43
        end
44
      end
45
    else
46
      render plain: "Barcode #{barcode} not valid.", status: :not_found
×
47
    end
48
  rescue StandardError => e
49
    handle_alma_exception(exception: e, message: "Error for barcode: #{barcode}")
3✔
50
  end
51
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