Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
Metabase
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Engineering Digital Service
Metabase
Commits
b8adf4d5
Unverified
Commit
b8adf4d5
authored
7 months ago
by
Chris Truter
Committed by
GitHub
7 months ago
Browse files
Options
Downloads
Patches
Plain Diff
Fix query analysis clean up and add logging (#46651)
parent
1628d5fa
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/metabase/task/sweep_query_analysis.clj
+7
-4
7 additions, 4 deletions
src/metabase/task/sweep_query_analysis.clj
with
7 additions
and
4 deletions
src/metabase/task/sweep_query_analysis.clj
+
7
−
4
View file @
b8adf4d5
...
...
@@ -48,11 +48,11 @@
(
fn
([
final-count
]
final-count
)
([
running-count
ids
]
(
t2/delete!
:model/Query
Field
:id
[
:in
ids
])
(
t2/delete!
:model/Query
Analysis
:id
[
:in
ids
])
(
+
running-count
(
count
ids
))))
0
(
t2/reducible-select
[
:model/Query
Field
:id
]
{
:join
[[
:report_card
:c
]
[
:=
:c.id
:query_
field
.card_id
]]
(
t2/reducible-select
[
:model/Query
Analysis
: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."
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment