MDeadman commented on code in PR #38638:
URL: https://github.com/apache/superset/pull/38638#discussion_r2942991137


##########
superset/charts/data/api.py:
##########
@@ -156,6 +180,53 @@ def get_data(  # noqa: C901
         json_body["result_type"] = request.args.get("type", 
ChartDataResultType.FULL)
         json_body["force"] = request.args.get("force")
 
+        # Apply dashboard filter context when filters_dashboard_id is provided
+        dashboard_filter_context: DashboardFilterContext | None = None
+        filters_dashboard_id = request.args.get("filters_dashboard_id", 
type=int)
+        if filters_dashboard_id is not None:
+            try:
+                dashboard_filter_context = get_dashboard_filter_context(
+                    dashboard_id=filters_dashboard_id,
+                    chart_id=pk,
+                )
+            except ValueError as error:
+                return self.response_400(message=str(error))
+            except SupersetSecurityException:
+                return self.response_403()
+
+            if dashboard_filter_context.extra_form_data:
+                efd = dashboard_filter_context.extra_form_data
+                extra_filters = efd.get("filters", [])
+
+                for query in json_body.get("queries", []):
+                    if extra_filters:
+                        existing = query.get("filters", [])
+                        query["filters"] = existing + [
+                            {**f, "isExtra": True} for f in extra_filters
+                        ]
+
+                    extras = query.get("extras", {})
+                    for key in EXTRA_FORM_DATA_OVERRIDE_EXTRA_KEYS:
+                        if key in efd:
+                            extras[key] = efd[key]

Review Comment:
   Applied fix



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to