Vitor-Avila commented on code in PR #41214:
URL: https://github.com/apache/superset/pull/41214#discussion_r3443845070


##########
superset/charts/data/dashboard_filter_context.py:
##########
@@ -107,8 +98,7 @@ def _is_filter_in_scope_for_chart(
 
     # If the chart doesn't exist in the dashboard layout, treat it as a
     # root-level chart.
-    else:
-        return "ROOT_ID" in root_path
+    return "ROOT_ID" in root_path

Review Comment:
   `chartsInScope` is a denormalized cache derived from scope 
[ref](https://github.com/apache/superset/blob/master/superset-frontend/src/dashboard/util/calculateScopes.ts#L58-L62)
 (the type definition for `scope` is required, but for `chartsInScope` is 
optional 
[ref](https://github.com/apache/superset/blob/master/superset-frontend/packages/superset-ui-core/src/query/types/Dashboard.ts#L67-L90)).
 That said, we should always have a `scope` value (the app can't produce 
`chartsInScope` without a `scope`).
   
   The frontend does read `chartsInScope`, but it recomputes it from `scope` on 
every load before using it 
[ref](https://github.com/apache/superset/blob/master/superset-frontend/src/dashboard/components/DashboardBuilder/DashboardContainer.tsx#L203-L225),
 so `scope` is the real source of truth and the saved cache is never trusted 
as-is. The gap is that this recompute lives in memory and is only persisted on 
an explicit save, so the stored `chartsInScope` drifts stale while the UI stays 
correct. 
   
   With that in mind, computing from scope (what this PR does, mirroring 
`calculateScopes`/`getChartIdsInFilterScope`) is the backend equivalent of the 
frontend's recompute.



-- 
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