Class: NurseAndrea::Backfill

Inherits:
Object
  • Object
show all
Defined in:
lib/nurse_andrea/backfill.rb

Constant Summary collapse

BATCH_SIZE =
500
MARKER_FILE =
".nurse_andrea_backfill_done"

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.run_async!Object



9
10
11
12
13
14
# File 'lib/nurse_andrea/backfill.rb', line 9

def self.run_async!
  Thread.new { new.run }.tap do |t|
    t.abort_on_exception = false
    t.name = "NurseAndrea::Backfill"
  end
end

Instance Method Details

#runObject



16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/nurse_andrea/backfill.rb', line 16

def run
  return unless should_run?

  log_file = resolve_log_file
  return unless log_file && File.exist?(log_file)

  entries = parse_log_file(log_file)
  ship_in_batches(entries)
  mark_complete!
rescue => e
  warn "[NurseAndrea] Backfill error: #{e.message}" if NurseAndrea.config.debug
end