app/models/util/updater.rb
# 1. adding all the sanity check issues to the load event
# 2. Verify that the sanity checks ran no more than 2 hours ago
# 3. Verify that the number of studies in the alt database differs by at most 10 studies
1. adding all the sanity check issues to the load event
2. Verify that the sanity checks ran no more than 2 hours ago
3. Verify that the number of studies in the alt database differs by at most 10 studies
1 . adding all the sanity check issues to the load event 2 . Verify that the sanity checks ran no more than 2 hours ago 3 . Verify that the number of studies in the alt database differs by at most 10 studies
def sanity_checks_ok?
      log '  sanity checks ok?....'
      Support::SanityCheck.current_issues.each { |issue| load_event.add_problem(issue) }
      sanity_set = Support::SanityCheck.where(most_current: true)
      if sanity_set.max_by(&:created_at).created_at < (Time.zone.now - 2.hours)
        load_event.add_problem("Sanity checks ran more than 2 hours ago: #{sanity_set.max_by(&:created_at)}.")
      end
      old_count = db_mgr.public_study_count - 10
      new_count = Study.count
      if old_count > new_count
        load_event.add_problem("New db has fewer studies (#{new_count}) than current public db (#{old_count})")
      end
      log(load_event.problems) unless load_event.problems.blank?
      load_event.problems.blank?
    end
def sanity_checks_ok? log '  sanity checks ok?....' Support :: SanityCheck . current_issues . each { | issue | load_event . add_problem ( issue ) } sanity_set = Support :: SanityCheck . where ( most_current : true ) if sanity_set . max_by ( & :created_at ) . created_at < ( Time . zone . now - 2 . hours ) load_event . add_problem ( "Sanity checks ran more than 2 hours ago: #{sanity_set.max_by(&:created_at)}." ) end old_count = db_mgr . public_study_count - 10 new_count = Study . count if old_count > new_count load_event . add_problem ( "New db has fewer studies (#{new_count}) than current public db (#{old_count})" ) end log ( load_event . problems ) unless load_event . problems . blank? load_event . problems . blank? end
1. adding all the sanity check issues to the load event
2.
1 . adding all the sanity check issues to the load event 2 .
# add all issues to the load event # load all the sanity checks # because ct.gov cleans up and removes duplicate studies, # sometimes the new count is a bit less then the old count. # Fudge up by 10 studies to avoid incorrectly preventing a # refresh due to ct.gov having deleted studies.