Skip to content
Snippets Groups Projects
Unverified Commit b8adf4d5 authored by Chris Truter's avatar Chris Truter Committed by GitHub
Browse files

Fix query analysis clean up and add logging (#46651)

parent 1628d5fa
No related branches found
No related tags found
No related merge requests found
......@@ -48,11 +48,11 @@
(fn
([final-count] final-count)
([running-count ids]
(t2/delete! :model/QueryField :id [:in ids])
(t2/delete! :model/QueryAnalysis :id [:in ids])
(+ running-count (count ids))))
0
(t2/reducible-select [:model/QueryField :id]
{:join [[:report_card :c] [:= :c.id :query_field.card_id]]
(t2/reducible-select [:model/QueryAnalysis :id]
{:join [[:report_card :c] [:= :c.id :query_analysis.card_id]]
:where :c.archived})))
(defn- sweep-query-analysis-loop!
......@@ -66,16 +66,19 @@
(query-analysis/analyze-sync! card-or-id))))
([first-time? analyze-fn]
;; prioritize cards that are missing analysis
(log/info "Calculating analysis for cards without any")
(analyze-cards-without-query-fields! analyze-fn)
;; we run through all the existing analysis on our first run, as it may be stale due to an old macaw version, etc.
(when first-time?
(log/info "Recalculating potentially stale analysis")
;; this will repeat the cards we've just back-filled, but in the steady state there should be none of those.
;; in the future, we will track versions, hashes, and timestamps to reduce the cost of this operation.
(analyze-stale-cards! analyze-fn))
;; empty out useless records
(delete-orphan-analysis!)))
(log/info "Deleting analysis for archived cards")
(log/infof "Deleted analysis for %s cards" (delete-orphan-analysis!))))
(jobs/defjob ^{DisallowConcurrentExecution true
:doc "Backfill QueryField for cards created earlier. Runs once per instance."}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment