trentontrees commented on code in PR #34418:
URL: https://github.com/apache/superset/pull/34418#discussion_r2280256204


##########
superset/commands/dashboard/importers/v1/utils.py:
##########
@@ -159,27 +159,38 @@ def update_cross_filter_scoping(
         ]
 
     if "chart_configuration" in (metadata := fixed.get("metadata", {})):
-        # in cross_filter_scopes the key is the chart ID as a string; we need 
to update
-        # them to be the new ID as a string:
-        metadata["chart_configuration"] = {
-            str(id_map[int(old_id)]): columns
-            for old_id, columns in metadata["chart_configuration"].items()
-            if int(old_id) in id_map
-        }
-        # now update scope excluded to use new IDs:
-        for chart_config in metadata["chart_configuration"].values():
-            if "id" in chart_config and chart_config["id"] in id_map:
-                chart_config["id"] = id_map[chart_config["id"]]
-            scope = chart_config.get("crossFilters", {}).get("scope", {})
+        # Build remapped configuration in a single pass for 
clarity/readability.
+        new_chart_configuration: dict[str, Any] = {}
+        for old_id_str, chart_config in 
metadata["chart_configuration"].items():
+            try:
+                old_id_int = int(old_id_str)
+            except (TypeError, ValueError):
+                continue
 
-            if not isinstance(scope, dict):
+            new_id = id_map.get(old_id_int)
+            if new_id is None:
                 continue
 
-            excluded_scope = scope.get("excluded", [])
-            if excluded_scope:
-                chart_config["crossFilters"]["scope"]["excluded"] = [
-                    id_map[old_id] for old_id in excluded_scope if old_id in 
id_map
-                ]
+            # Update inner id if present
+            if isinstance(chart_config, dict):

Review Comment:
   unit tests continue to pass, :shipit:  



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