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

pulibrary / bibdata / fa8448dd-0600-47e7-8889-1dfa562d11f0

05 Sep 2023 08:01PM UTC coverage: 86.172% (-4.9%) from 91.048%
fa8448dd-0600-47e7-8889-1dfa562d11f0

push

circleci

sandbergja
i2239: Use SRU instead of Alma API for bib record retrieval

8 of 8 new or added lines in 2 files covered. (100.0%)

3309 of 3840 relevant lines covered (86.17%)

326.63 hits per line

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

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

4
  def index
1✔
5
    if params[:barcode]
1✔
6
      redirect_to action: :barcode, barcode: params[:barcode], status: :moved_permanently
×
7
    else
8
      render plain: "Please supply a barcode.", status: :not_found
1✔
9
    end
10
  end
11

12
  # Client: This endpoint is used by the ReCAP inventory management system, LAS,
13
  #   to pull data from our ILS when items are accessioned
14
  def scsb
1✔
15
    barcode = params[:barcode]
2✔
16
    if !valid_barcode?(barcode)
2✔
17
      render plain: "Barcode #{barcode} not valid.", status: :not_found
×
18
    else
19
      adapter = AlmaAdapter.new
2✔
20
      item = adapter.item_by_barcode(barcode)
2✔
21
      mms_id = item["bib_data"]["mms_id"]
×
22
      record = adapter.get_bib_record(mms_id)
×
23

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