feature: Adding extra_filters to warm_up_cache (#10675)
Co-authored-by: John Bodley <john.bodley@airbnb.com>
This commit is contained in:
parent
fe574fdaa7
commit
502f4db6f9
|
|
@ -1431,12 +1431,16 @@ class Superset(BaseSupersetView): # pylint: disable=too-many-public-methods
|
|||
"""Warms up the cache for the slice or table.
|
||||
|
||||
Note for slices a force refresh occurs.
|
||||
|
||||
In terms of the `extra_filters` these can be obtained from records in the JSON
|
||||
encoded `logs.json` column associated with the `explore_json` action.
|
||||
"""
|
||||
session = db.session()
|
||||
slice_id = request.args.get("slice_id")
|
||||
dashboard_id = request.args.get("dashboard_id")
|
||||
table_name = request.args.get("table_name")
|
||||
db_name = request.args.get("db_name")
|
||||
extra_filters = request.args.get("extra_filters")
|
||||
|
||||
if not slice_id and not (table_name and db_name):
|
||||
return json_error_response(
|
||||
|
|
@ -1482,8 +1486,10 @@ class Superset(BaseSupersetView): # pylint: disable=too-many-public-methods
|
|||
try:
|
||||
form_data = get_form_data(slc.id, use_slice_data=True)[0]
|
||||
if dashboard_id:
|
||||
form_data["extra_filters"] = get_dashboard_extra_filters(
|
||||
slc.id, dashboard_id
|
||||
form_data["extra_filters"] = (
|
||||
json.loads(extra_filters)
|
||||
if extra_filters
|
||||
else get_dashboard_extra_filters(slc.id, dashboard_id)
|
||||
)
|
||||
|
||||
obj = get_viz(
|
||||
|
|
|
|||
|
|
@ -576,6 +576,17 @@ class TestCore(SupersetTestCase):
|
|||
)
|
||||
assert len(data) > 0
|
||||
|
||||
dashboard = self.get_dash_by_slug("births")
|
||||
|
||||
assert self.get_json_resp(
|
||||
f"/superset/warm_up_cache?dashboard_id={dashboard.id}&slice_id={slc.id}"
|
||||
) == [{"slice_id": slc.id, "viz_error": None, "viz_status": "success"}]
|
||||
|
||||
assert self.get_json_resp(
|
||||
f"/superset/warm_up_cache?dashboard_id={dashboard.id}&slice_id={slc.id}&extra_filters="
|
||||
+ quote(json.dumps([{"col": "name", "op": "in", "val": ["Jennifer"]}]))
|
||||
) == [{"slice_id": slc.id, "viz_error": None, "viz_status": "success"}]
|
||||
|
||||
def test_shortner(self):
|
||||
self.login(username="admin")
|
||||
data = (
|
||||
|
|
|
|||
Loading…
Reference in New Issue