• 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

48.28
/app/models/dump.rb
1
require 'zip'
1✔
2
require 'net/sftp'
1✔
3
require 'date'
1✔
4

5
class Dump < ActiveRecord::Base
1✔
6
  ENQUEUED = 'enqueued'.freeze
1✔
7
  STARTED = 'started'.freeze
1✔
8
  DONE = 'done'.freeze
1✔
9

10
  belongs_to :event
1✔
11
  has_many :dump_files
1✔
12
  # These only apply to change dumps (stored in db rather than text files)
13
  serialize :delete_ids
1✔
14
  serialize :update_ids
1✔
15
  serialize :recap_barcodes
1✔
16
  validates :event_id, presence: true
1✔
17

18
  before_destroy do
1✔
UNCOV
19
    self.dump_files.each do |df|
×
UNCOV
20
      df.destroy
×
21
    end
22
  end
23

24
  enum dump_type: {
1✔
25
    full_dump: 1,
26
    changed_records: 2,
27
    princeton_recap: 3,
28
    partner_recap: 4,
29
    partner_recap_full: 5,
30
    bib_ids: 6,
31
    merged_ids: 7
32
  }
33

34
  class << self
1✔
35
    ##
36
    # Create a dump of partner recap incremental records.
37
    def partner_update
1✔
UNCOV
38
      dump = nil
×
UNCOV
39
      timestamp = incremental_update_timestamp.to_s
×
UNCOV
40
      Event.record do |event|
×
UNCOV
41
        event.save
×
UNCOV
42
        dump = Dump.create(dump_type: :partner_recap, event_id: event.id)
×
UNCOV
43
        Import::Partner::Incremental.perform_async(dump.id, timestamp)
×
UNCOV
44
        dump.save
×
45
      end
UNCOV
46
      dump
×
47
    end
48

49
    def latest_generated
1✔
UNCOV
50
      order('generated_date desc').first
×
51
    end
52

53
    def generated_date(dump_id)
1✔
UNCOV
54
      dump = Dump.find(dump_id)
×
UNCOV
55
      dump.generated_date = dump.date_strings.map { |str| DateTime.parse(str) }.min
×
UNCOV
56
      dump.save!
×
57
    end
58

59
    def attach_dump_file(dump_id, file_path, dump_file_type = nil)
1✔
UNCOV
60
      dump = Dump.find(dump_id)
×
UNCOV
61
      df = DumpFile.create(dump_file_type:, path: file_path)
×
UNCOV
62
      df.zip
×
UNCOV
63
      df.save
×
UNCOV
64
      dump.dump_files << df
×
UNCOV
65
      dump.save
×
66
    end
67

68
    private
1✔
69

70
      ##
71
      # Figure out when was the last time we got partner update records, and find
72
      # anything that has appeared since then. The ways we can know the last time
73
      # we got partner update records are:
74
      # * via an environment variable
75
      # * look for the last partner recap dump and get its creation date
76
      # * or, if neither of those, use yesterday
77
      def incremental_update_timestamp
1✔
UNCOV
78
        (ENV.fetch('TIMESTAMP', nil) || last_incremental_update || (DateTime.now - 1)).to_time.strftime('%Y-%m-%d %H:%M:%S.%6N %z')
×
79
      end
80

81
      def last_incremental_update
1✔
UNCOV
82
        Dump.partner_recap.last&.created_at
×
83
      end
84
  end # class << self
85

86
  def date_strings
1✔
UNCOV
87
    dump_files.map do |df|
×
UNCOV
88
      if df.dump_file_type == 'recap_records_full_metadata'
×
UNCOV
89
        File.basename(df.path).split('_')[3]
×
90
      else
UNCOV
91
        File.basename(df.path).split('_')[2]
×
92
      end
93
    end
94
  end
95

96
  def subsequent_partner_incrementals
1✔
UNCOV
97
    Dump.partner_recap.where(generated_date: generated_date..Float::INFINITY)
×
98
  end
99

100
  def enqueued?
1✔
101
    index_status == ENQUEUED
×
102
  end
103

104
  def started?
1✔
105
    index_status == STARTED
×
106
  end
107

108
  def done?
1✔
109
    index_status == DONE
×
110
  end
111
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