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

pulibrary / bibdata / 373ad6ff-fad2-405a-ab26-3d30fb5ceecf

24 Dec 2024 08:24PM UTC coverage: 91.938% (+0.08%) from 91.859%
373ad6ff-fad2-405a-ab26-3d30fb5ceecf

Pull #2563

circleci

maxkadel
Put attaching xml files in their own batch
Pull Request #2563: I2321 Shift SCSB full index tasks into separate background jobs

152 of 156 new or added lines in 10 files covered. (97.44%)

65 existing lines in 17 files now uncovered.

3478 of 3783 relevant lines covered (91.94%)

366.14 hits per line

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

79.49
/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: sanitized_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]
7✔
16
    if !valid_barcode?(barcode)
7✔
UNCOV
17
      render plain: "Barcode #{barcode} not valid.", status: :not_found
×
18
    else
19
      adapter = AlmaAdapter.new
7✔
20
      item = adapter.item_by_barcode(barcode)
7✔
21
      mms_id = item["bib_data"]["mms_id"]
5✔
22
      record = adapter.get_bib_record(mms_id, show_suppressed: true)
5✔
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?
5✔
UNCOV
26
        render plain: "Record #{mms_id} not found", status: :not_found
×
UNCOV
27
        return
×
28
      end
29
      holding = adapter.holding_by_id(mms_id:, holding_id: item.holding_data["holding_id"])
5✔
30
      records = if record.linked_record_ids.present?
4✔
31
                  adapter.get_bib_records(record.linked_record_ids)
1✔
32
                else
33
                  [record]
3✔
34
                end
35
      records.each do |bib_record|
4✔
36
        bib_record.enrich_with_item(item)
5✔
37
        bib_record.delete_conflicting_holding_data!
5✔
38
        bib_record.enrich_with_holding(holding, recap: true)
5✔
39
        bib_record.strip_non_numeric!
5✔
40
      end
41
      if records == []
4✔
UNCOV
42
        render plain: "Barcode #{barcode} not found.", status: :not_found
×
43
      else
44
        respond_to do |wants|
4✔
45
          wants.json  do
4✔
UNCOV
46
            json = MultiJson.dump(pass_records_through_xml_parser(records))
×
UNCOV
47
            render json:
×
48
          end
49
          wants.xml do
4✔
50
            xml = records_to_xml_string(records)
4✔
51
            render xml:
4✔
52
          end
53
        end
54
      end
55
    end
56
  rescue => e
57
    handle_alma_exception(exception: e, message: "Error for barcode: #{barcode}")
3✔
58
  end
59

60
  private
1✔
61

62
    def sanitized_barcode
1✔
63
      CGI.escape(params[:barcode])
×
64
    end
65
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