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

pulibrary / bibdata / 1dcebae2-3318-4e77-bc53-82276e293354

02 May 2025 04:45PM UTC coverage: 28.256% (-63.9%) from 92.189%
1dcebae2-3318-4e77-bc53-82276e293354

push

circleci

sandbergja
Add basic infrastructure for compiling rust code

* Add a rake compile task to compile
* Run the rake task in CI
* Run the rake task before rspec tests with the rust tag, to provide quick feedback on rust changes in TDD cycles

2 of 7 new or added lines in 2 files covered. (28.57%)

2467 existing lines in 97 files now uncovered.

1089 of 3854 relevant lines covered (28.26%)

0.29 hits per line

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

47.37
/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, coder: YAML
1✔
14
  serialize :update_ids, coder: YAML
1✔
15
  validates :event_id, presence: true
1✔
16

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

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

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

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

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

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

67
    private
1✔
68

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

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

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

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

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

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

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