• 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

52.17
/app/services/location_maps_generator_service.rb
1
class LocationMapsGeneratorService
1✔
2
  def self.generate
1✔
UNCOV
3
    new.generate
×
4
  end
5

6
  def self.generate_from_templates
1✔
7
    new.generate_from_templates
1✔
8
  end
9

10
  attr_reader :base_path, :logger
1✔
11

12
  def initialize(base_path: Rails.root.join('marc_to_solr', 'translation_maps'), logger: Rails.logger)
1✔
13
    @base_path = base_path
1✔
14
    @logger = logger
1✔
15
  end
16

17
  def generate
1✔
UNCOV
18
    return unless holding_locations_table_exists?
×
19

UNCOV
20
    lib_display = {}
×
UNCOV
21
    locations_display = {}
×
UNCOV
22
    locations.each do |holding|
×
UNCOV
23
      holding_code = holding['code']
×
UNCOV
24
      lib_label = holding.library['label']
×
25
      # The locations.rb file needs to have the scsb locations as e.g "scsbnypl"=>"ReCAP".
26
      # This is why we are pulling the library label only for the scsb locations.
27
      # The rest of the holding_location_library records will take the holding['label'] value, even if it is blank.
28
      # This change will reflect on the holdings1_display["location"] value since it is using the locations.rb file for the location field.
29
      # see https://github.com/pulibrary/bibdata/blob/fe0a9b9495b7a8275f5a64463257c06537dd9c1e/marc_to_solr/lib/princeton_marc.rb#L653 for more info.
UNCOV
30
      holding_label = holding['label']
×
UNCOV
31
      lib_display[holding_code] = lib_label
×
UNCOV
32
      locations_display[holding_code] = holding_label
×
33
    end
UNCOV
34
    write_file('location_display.rb', lib_display)
×
UNCOV
35
    write_file('locations.rb', locations_display)
×
36
  end
37

38
  def generate_from_templates
1✔
39
    copy_template('locations.rb.tmpl')
1✔
40
    copy_template('location_display.rb.tmpl')
1✔
41
    copy_template('holding_library.rb.tmpl')
1✔
42
  end
43

44
  private
1✔
45

46
    def copy_template(template_name)
1✔
47
      output_file_name = template_name.gsub('.tmpl', '')
3✔
48
      output_file_path = file_path(output_file_name)
3✔
49
      template_file_path = file_path(template_name)
3✔
50
      FileUtils.cp(template_file_path, output_file_path)
3✔
51
    end
52

53
    def file_path(name)
1✔
54
      File.join(base_path, name)
6✔
55
    end
56

57
    def holding_locations_table_exists?
1✔
UNCOV
58
      if ActiveRecord::Base.connection.table_exists?('locations_holding_locations')
×
UNCOV
59
        true
×
60
      else
UNCOV
61
        logger.warn('Failed to seed the holding locations for Traject as the database table has not been created. Please invoke bundle exec rake db:create')
×
UNCOV
62
        false
×
63
      end
64
    rescue StandardError => e
UNCOV
65
      logger.warn("Failed to seed the holding locations for Traject due to a database error: #{e}.")
×
UNCOV
66
      false
×
67
    end
68

69
    def locations
1✔
UNCOV
70
      HoldingLocation.all
×
71
    end
72

73
    def write_file(file_name, values)
1✔
UNCOV
74
      path = file_path(file_name)
×
UNCOV
75
      File.open(path, 'w') do |file|
×
UNCOV
76
        PP.pp(values, file)
×
77
      end
78
    end
79
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