From a65463e7d36c90dbd5c71bbd51e90702a408ddc6 Mon Sep 17 00:00:00 2001 From: akabishau Date: Mon, 3 Jun 2024 08:53:50 -0400 Subject: [PATCH] make execute kick off event schema dependent --- app/models/util/updater_v2.rb | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/app/models/util/updater_v2.rb b/app/models/util/updater_v2.rb index 92344e7b..7923d1a1 100644 --- a/app/models/util/updater_v2.rb +++ b/app/models/util/updater_v2.rb @@ -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 @@ -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? @@ -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 @@ -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