This is an automated email from the ASF dual-hosted git repository. beto pushed a commit to branch fix_granularity_sqla in repository https://gitbox.apache.org/repos/asf/superset.git
commit 2454c2ed92a44e2512573fa51684bc4ab134bb8a Author: Beto Dealmeida <[email protected]> AuthorDate: Wed Sep 6 12:19:15 2023 -0700 fix: granularity_sqla and GENERIC_CHART_AXES --- superset/legacy.py | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/superset/legacy.py b/superset/legacy.py index 7c25d2de98..52b63a013b 100644 --- a/superset/legacy.py +++ b/superset/legacy.py @@ -17,10 +17,27 @@ """Code related with dealing with legacy / change management""" from typing import Any +from superset import is_feature_enabled + def update_time_range(form_data: dict[str, Any]) -> None: - """Move since and until to time_range.""" + """ + Legacy adjustments to time range. + + - Move `since` and `until` to `time_range`. + - Define `time_range` when `granularity_sqla` is set and unfiltered. + + """ if "since" in form_data or "until" in form_data: - form_data[ - "time_range" - ] = f'{form_data.pop("since", "") or ""} : {form_data.pop("until", "") or ""}' + since = form_data.pop("since", "") or "" + until = form_data.pop("until", "") or "" + form_data["time_range"] = f"{since} : {until}" + + if is_feature_enabled("GENERIC_CHART_AXES"): + if temporal_column := form_data.get("granularity_sqla"): + if any( + adhoc_filter.get("subject") == temporal_column + and adhoc_filter.get("comparator") == "No filter" + for adhoc_filter in form_data.get("adhoc_filters", []) + ): + form_data.setdefault("time_range", "No filter")
