Skip to content
This repository has been archived by the owner on Nov 3, 2023. It is now read-only.

Commit

Permalink
fix: Missing applied filters indicator (apache#22137)
Browse files Browse the repository at this point in the history
  • Loading branch information
john-bodley committed Nov 16, 2022
1 parent d76f305 commit e8a0a5e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
5 changes: 2 additions & 3 deletions superset/utils/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -1182,8 +1182,7 @@ def merge_extra_filters(form_data: Dict[str, Any]) -> None:
# that are external to the slice definition. We use those for dynamic
# interactive filters like the ones emitted by the "Filter Box" visualization.
# Note extra_filters only support simple filters.
applied_time_extras: Dict[str, str] = {}
form_data["applied_time_extras"] = applied_time_extras
form_data.setdefault("applied_time_extras", {})
adhoc_filters = form_data.get("adhoc_filters", [])
form_data["adhoc_filters"] = adhoc_filters
merge_extra_form_data(form_data)
Expand Down Expand Up @@ -1226,7 +1225,7 @@ def get_filter_key(f: Dict[str, Any]) -> str:
time_extra_value = filtr.get("val")
if time_extra_value and time_extra_value != NO_TIME_RANGE:
form_data[time_extra] = time_extra_value
applied_time_extras[filter_column] = time_extra_value
form_data["applied_time_extras"][filter_column] = time_extra_value
elif filtr["val"]:
# Merge column filters
filter_key = get_filter_key(filtr)
Expand Down
12 changes: 12 additions & 0 deletions tests/integration_tests/utils_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -539,6 +539,18 @@ def test_merge_extra_filters_adds_unequal_lists(self):
merge_extra_filters(form_data)
self.assertEqual(form_data, expected)

def test_merge_extra_filters_when_applied_time_extras_predefined(self):
form_data = {"applied_time_extras": {"__time_range": "Last week"}}
merge_extra_filters(form_data)

self.assertEqual(
form_data,
{
"applied_time_extras": {"__time_range": "Last week"},
"adhoc_filters": [],
},
)

def test_merge_request_params_when_url_params_undefined(self):
form_data = {"since": "2000", "until": "now"}
url_params = {"form_data": form_data, "dashboard_ids": "(1,2,3,4,5)"}
Expand Down

0 comments on commit e8a0a5e

Please sign in to comment.