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

pulibrary / bibdata / f04bc944-f9b4-4a42-8b26-dcacd0e3e688

11 Mar 2025 10:27PM UTC coverage: 34.017% (-58.1%) from 92.162%
f04bc944-f9b4-4a42-8b26-dcacd0e3e688

Pull #2653

circleci

christinach
Add new lc_subject_facet field.
Helps with the vocabulary work https://github.com/pulibrary/orangelight/pull/3386
In this new field we index only the lc subject heading and the subdivisions
So that when the user searches using the Details section, they can query solr for
all the subject headings and their divisions.

This is needed for the Subject browse Vocabulary work.
example: "lc_subject_facet": [
             "Booksellers and bookselling—Italy—Directories",
             "Booksellers and bookselling-Italy",
             "Booksellers and bookselling"
              ]
Pull Request #2653: Add new lc_subject_facet field.

1 of 3 new or added lines in 1 file covered. (33.33%)

2215 existing lines in 93 files now uncovered.

1294 of 3804 relevant lines covered (34.02%)

0.99 hits per line

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

21.88
/app/controllers/concerns/formatting_concern.rb
1
module FormattingConcern
1✔
2
  extend ActiveSupport::Concern
1✔
3
  # @param records [MARC::Record] Could be one or a collection
4
  # @return [String] A serialized <mrx:record/> or <mrx:collection/>
5
  # "Cleans" the record of invalid xml characters
6
  def records_to_xml_string(records)
1✔
UNCOV
7
    if records.kind_of? Array
×
UNCOV
8
      xml_str = ''
×
UNCOV
9
      StringIO.open(xml_str) do |io|
×
UNCOV
10
        writer = MARC::XMLWriter.new(io)
×
UNCOV
11
        records.each do |r|
×
UNCOV
12
          writer.write(r) unless r.nil?
×
13
        end
UNCOV
14
        writer.close()
×
15
      end
UNCOV
16
      valid_xml(xml_str)
×
UNCOV
17
    elsif records.kind_of? String
×
18
      # example response from /almaws/v1/bibs/{mms_id}/holdings
UNCOV
19
      valid_xml(records)
×
20
    else
UNCOV
21
      valid_xml(records.to_xml.to_s)
×
22
    end
23
  end
24

25
  # Moved from voyager-helpers
26
  # strips invalid xml characters to prevent parsing errors
27
  # only used for "cleaning" individually retrieved records
28
  def valid_xml(xml_string)
1✔
UNCOV
29
    invalid_xml_range = /[^\u0009\u000A\u000D\u0020-\uD7FF\uE000-\uFFFD]/
×
UNCOV
30
    xml_string.gsub(invalid_xml_range, '')
×
31
  end
32

33
  # Clean up character encoding problems by passing the
34
  # records through an XML parser
35
  # @param records [MARC::Record] Could be one or a collection
36
  # @return [Hash] If only one record was passed
37
  # @return [Array<Hash>]
38
  def pass_records_through_xml_parser(records)
1✔
39
    reader = MARC::XMLReader.new(StringIO.new(records_to_xml_string(records)))
×
40
    record_hashes = []
×
41
    reader.each { |r| record_hashes << r.to_hash }
×
42
    if record_hashes.length == 1
×
43
      record_hashes.first
×
44
    else
45
      record_hashes
×
46
    end
47
  end
48

49
  def valid_barcode?(barcode)
1✔
UNCOV
50
    (barcode =~ /^(32101[0-9]{9}|PULTST[0-9]{5})$/) == 0
×
51
  end
52

53
  def statuses_to_xml(data)
1✔
54
    # yep!
55
    s = []
×
56
    s << '<statuses>'
×
57
    data.each { |k, v| s << %(<status code="#{k}" label="#{v}" />) }
×
58
    s << '</statuses>'
×
59
    s.join('')
×
60
  end
61
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