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 c2e225426d71e80b1053c668f8301411488b155c
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..49772e409d 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.
+        - Apply time_range when granularity_sqla is set.
+
+    """
     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"):
+            for adhoc_filter in form_data.get("adhoc_filters", []):
+                if (
+                    adhoc_filter["subject"] == temporal_column
+                    and adhoc_filter["comparator"] == "No filter"
+                ):
+                    form_data["time_range"] = "No filter"

Reply via email to