Skip to content

Commit

Permalink
make execute kick off event schema dependent
Browse files Browse the repository at this point in the history
  • Loading branch information
akabishau committed Jun 3, 2024
1 parent acb32be commit a65463e
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions app/models/util/updater_v2.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ def initialize(params = {})

def run_main_loop
loop do
now = TZInfo::Timezone.get('America/New_York').now
if Support::LoadEvent.where('created_at > ?',now.beginning_of_day).count == 0
now = TZInfo::Timezone.get("America/New_York").now
if Support::LoadEvent.where("created_at > ? AND description LIKE ?", now.beginning_of_day, "#{@schema}%").count == 0
execute
else
ActiveRecord::Base.logger = nil
Expand Down Expand Up @@ -43,7 +43,12 @@ def execute

log("#{@schema}: EXECUTE started")

@load_event = Support::LoadEvent.create({ event_type: @type, status: 'running', description: "#{@schema}", problems: '' })
@load_event = Support::LoadEvent.create({
event_type: @type,
status: "running",
description: "#{@schema}",
problems: ""
})

ActiveRecord::Base.logger = nil # why are we disabling logger here?

Expand Down Expand Up @@ -94,7 +99,8 @@ def execute
@load_event.run_sanity_checks(@schema)
@load_event.log("8/11 ran sanity checks")

if load_even.sanity_checks.count == 0
# TODO: sanity checks return error - load_event -> problems
if @load_even.sanity_checks.count == 0
puts "SANITY CHECKS PASSED"
# 9. take snapshot

Expand Down Expand Up @@ -138,6 +144,7 @@ def update_studies
puts "Time: #{time} avg: #{time / total}"
end

# TODO: Not called anywhere - verify that correct schema is being used
def remove_studies
# remove studies
raise "Removing too many studies #{to_remove.count}" if Study.count <= to_remove.count
Expand Down

0 comments on commit a65463e

Please sign in to comment.