-
- Downloads
Handle archived and models reverted to regular questions (#23738)
* Handle archived and models reverted to regular questions Should not refresh these and should unpersist them Updated the signature of `refresh!` in the `Refresher` protocol to take a card instead of a dataset query so that the tests could use the card's id for checks. The `dispatching-refresher` then calls the `ddl.i/refresh!` multimethod with the dataset_query from the card so its a very surface level refactoring. Updated the stats from refreshing to be a bit smarter. It used to have a `when` block for its check against the model's state. this meant on a state change that prevented refreshing it would throw away accumulated stats. Whoops. Now it records that as a skip. The check itself has grown to check archived and dataset status of the underlying card. * Block api/card/card-id/refresh from refreshing archived/unmodeled From page http://localhost:3000/admin/tools/model-caching we have a list of PersistedInfo records and a way to refresh them. We've already prevented the scheduled tasks from refreshing archived/unmodeled questions and now the api won't let a user manually do it either. * ns linter demands allegiance * Include card archived and dataset information on api/persist Include information so that the frontend can disallow refreshing models based on cards that are archived or no longer archived. The response from `http://localhost:3000/api/persist?limit=20&offset=0` now includes two new attributes on the items in the data array: `"card_archived"` and `"card_dataset"`. I'm happy to rename if desired. These are present so that if `card_archived=true` or `card_dataset=false` we should not allow refreshing the persisted model. The API will already reject this request with a 400 so we should let the user know why this is no longer valid. I'm happy to leave them as the regular property names `archived` and `dataset` but put them with the `card_` prefix so it is clear that these are not properties of a PersistedInfo but the card that the persisted info references ``` { "data": [ { "definition": { "table-name": "model_3_model_from", "field-definitions": [ { "field-name": "id", "base-type": "type/Integer" }, { "field-name": "total", "base-type": "type/Float" }, { "field-name": "quantity", "base-type": "type/Integer" } ] }, "creator": null, "schema_name": "metabase_cache_944b9_2", "database_id": 2, "collection_id": null, "database_name": "sample dataset pg", "state": "persisted", "refresh_begin": "2022-07-07T14:22:51.512016Z", "refresh_end": "2022-07-07T14:22:51.52032Z", "collection_name": null, "collection_authority_level": null, "creator_id": null, "card_archived": true, <---- new "active": true, "id": 3, "card_dataset": true, <---- new "card_id": 3, "error": null, "next-fire-time": null, "table_name": "model_3_model_from", "card_name": "model from orders archived" }, { "definition": { "table-name": "model_2_model_from", "field-definitions": [ { "field-name": "id", "base-type": "type/Integer" }, { "field-name": "total", "base-type": "type/Float" }, { "field-name": "quantity", "base-type": "type/Integer" } ] }, "creator": null, "schema_name": "metabase_cache_944b9_2", "database_id": 2, "collection_id": null, "database_name": "sample dataset pg", "state": "persisted", "refresh_begin": "2022-07-07T14:22:33.509687Z", "refresh_end": "2022-07-07T14:22:33.517815Z", "collection_name": null, "collection_authority_level": null, "creator_id": null, "card_archived": false, <---- new "active": true, "id": 2, "card_dataset": false, <---- new "card_id": 2, "error": null, "next-fire-time": null, "table_name": "model_2_model_from", "card_name": "model from orders no longer model" }, { "definition": { "table-name": "model_1_model_from", "field-definitions": [ { "field-name": "id", "base-type": "type/Integer" }, { "field-name": "total", "base-type": "type/Float" }, { "field-name": "quantity", "base-type": "type/Integer" } ] }, "creator": null, "schema_name": "metabase_cache_944b9_2", "database_id": 2, "collection_id": null, "database_name": "sample dataset pg", "state": "persisted", "refresh_begin": "2022-07-07T14:22:33.476072Z", "refresh_end": "2022-07-07T14:22:33.504025Z", "collection_name": null, "collection_authority_level": null, "creator_id": null, "card_archived": false, <---- new "active": true, "id": 1, "card_dataset": true, <---- new "card_id": 1, "error": null, "next-fire-time": null, "table_name": "model_1_model_from", "card_name": "model from orders" } ], "total": 3, "limit": 20, "offset": 0 } ``` * Add conditions to checkCanRefreshModelCache (#23778) Co-authored-by:Gustavo Saiani <gustavo@poe.ma>
Showing
- frontend/src/metabase-types/api/models.ts 2 additions, 0 deletionsfrontend/src/metabase-types/api/models.ts
- frontend/src/metabase/lib/data-modeling/utils.ts 8 additions, 0 deletionsfrontend/src/metabase/lib/data-modeling/utils.ts
- src/metabase/api/card.clj 6 additions, 1 deletionsrc/metabase/api/card.clj
- src/metabase/api/persist.clj 2 additions, 0 deletionssrc/metabase/api/persist.clj
- src/metabase/task/persist_refresh.clj 59 additions, 17 deletionssrc/metabase/task/persist_refresh.clj
- test/metabase/api/card_test.clj 61 additions, 3 deletionstest/metabase/api/card_test.clj
- test/metabase/task/persist_refresh_test.clj 31 additions, 12 deletionstest/metabase/task/persist_refresh_test.clj
Loading
Please register or sign in to comment