• 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

51.72
/app/adapters/alma_adapter/marc_record.rb
1
class AlmaAdapter
1✔
2
  # Adds functionality to an Alma::Bib to handle the various ways we manipulate
3
  # or access the MARC data for an individual record.
4
  class MarcRecord < SimpleDelegator
1✔
5
    attr_reader :bib, :marc_record
1✔
6

7
    # @param bib [Alma::Bib]
8
    # @param marc_record [MARC::Record]
9
    # @note We accept these two separately because parsing a bunch of MARC
10
    # records at once is more performant than doing one at a time, so it's
11
    # done before initializing this.
12
    def initialize(bib, marc_record)
1✔
13
      super(marc_record)
7✔
14
      @marc_record = marc_record
7✔
15
      @bib = bib
7✔
16
    end
17

18
    def suppressed?
1✔
19
      bib['suppress_from_publishing'] == 'true'
×
20
    end
21

22
    def linked_record_ids
1✔
UNCOV
23
      linked_record_fields = marc_record.fields('774').select do |field|
×
UNCOV
24
        alma_bib_id?(field['w']) && field['t']
×
25
      end
UNCOV
26
      linked_record_fields.map do |field|
×
UNCOV
27
        field['w']
×
28
      end
29
    end
30

31
    def enrich_with_item(item)
1✔
UNCOV
32
      item = ::AlmaAdapter::AlmaItem.new(item)
×
UNCOV
33
      marc_record.append(item.enrichment_876)
×
34
    end
35

36
    # Remove source record 852s and 86Xs, to reduce confusion when holding
37
    # data is added.
38
    def delete_conflicting_holding_data!
1✔
UNCOV
39
      marc_record.fields.delete_if { |f| %w[852 866 867 868].include? f.tag }
×
40
    end
41

42
    # Remove source record 876s. These probably come from a publishing job, and
43
    # if we're calling this they're probably getting added back via
44
    # enrich_with_item to enable further processing.
45
    def delete_conflicting_item_data!
1✔
46
      marc_record.fields.delete_if { |f| ['876'].include? f.tag }
×
47
    end
48

49
    # @param holding [Alma::BibHolding | AlmaAdapter::AlmaHolding] Either a
50
    #   holding from the API or an already built `AlmaAdapter::AlmaHolding`. The
51
    #   holding may already be built in the case of
52
    #   `AlmaAdapter::ScsbDumpRecord`
53
    def enrich_with_holding(holding, recap: false)
1✔
UNCOV
54
      holding = ::AlmaAdapter::AlmaHolding.for(holding, recap:) unless holding.respond_to?(:marc_record_enrichment)
×
UNCOV
55
      marc_record.fields.concat(holding.marc_record_enrichment)
×
56
    end
57

58
    # Strips non-numeric tags for ReCAP, whose parser can't handle them.
59
    def strip_non_numeric!
1✔
UNCOV
60
      marc_record.fields.delete_if do |field|
×
61
        # tag with non numeric character
UNCOV
62
        field.tag.scan(/^(\s|\D+)/).present?
×
63
      end
64
    end
65

66
    # Pass a specific field code to check if it is an alma id.
67
    def alma_bib_id?(code)
1✔
UNCOV
68
      code.to_s.start_with?('99') && code.to_s.end_with?('06421')
×
69
    end
70
  end
71
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