Skip to content

Commit

Permalink
Don't say we'll cache archived models (metabase#41329)
Browse files Browse the repository at this point in the history
When we actually run the job to cache models, we select "refreshable
models", which selects `PersistedInfo` where:

- the `state` is something refreshable, and

- the question marked for caching is actually a model, and

- the question hasn't been archived.

However, when we selected `PersistedInfo`s to display to the user, we
didn't apply any conditions. Instead, we included PersistedInfo where
the question was not a model, or where the question had been archived.

To prevent confusion, let's hide these.

Fixes metabase#41318
  • Loading branch information
johnswanson authored Apr 18, 2024
1 parent 427fbc1 commit 3706710
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/metabase/api/persist.clj
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@
:left-join [[:metabase_database :db] [:= :db.id :p.database_id]
[:report_card :c] [:= :c.id :p.card_id]
[:collection :col] [:= :c.collection_id :col.id]]
:where [:and
[:= :c.type "model"]
[:= :c.archived false]]
:order-by [[:p.refresh_begin :desc]]}
persisted-info-id (sql.helpers/where [:= :p.id persisted-info-id])
(seq db-ids) (sql.helpers/where [:in :p.database_id db-ids])
Expand Down Expand Up @@ -70,7 +73,12 @@
persisted-infos (fetch-persisted-info {:db-ids writable-db-ids} mw.offset-paging/*limit* mw.offset-paging/*offset*)]
{:data persisted-infos
:total (if (seq writable-db-ids)
(t2/count PersistedInfo :database_id [:in writable-db-ids])
(t2/count PersistedInfo {:from [[:persisted_info :p]]
:join [[:report_card :c] [:= :c.id :p.card_id]]
:where [:and
[:in :p.database_id writable-db-ids]
[:= :c.type "model"]
[:not :c.archived]]})
0)
:limit mw.offset-paging/*limit*
:offset mw.offset-paging/*offset*}))
Expand Down

0 comments on commit 3706710

Please sign in to comment.