Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Missing applied filters indicator #22137

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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