bito-code-review[bot] commented on code in PR #40008:
URL: https://github.com/apache/superset/pull/40008#discussion_r3216534923
##########
superset/commands/dashboard/export.py:
##########
@@ -230,3 +251,14 @@ def _export(
dataset = DatasetDAO.find_by_id(dataset_id)
if dataset:
yield from
ExportDatasetsCommand([dataset_id]).run()
+
+ # Export datasets referenced by display controls
+ for customization in (
+ payload.get("metadata", {}).get("chart_customization_config")
or []
+ ):
+ for target in customization.get("targets") or []:
+ dataset_id = target.get("datasetId")
+ if dataset_id is not None:
+ dataset = DatasetDAO.find_by_id(dataset_id)
+ if dataset:
+ yield from
ExportDatasetsCommand([dataset_id]).run()
Review Comment:
<div>
<div id="suggestion">
<div id="issue"><b>Semantic duplication in dataset export</b></div>
<div id="fix">
Similar to the _file_content method, this duplicates dataset export logic
for display controls. Refactor to share code with native filter handling.
</div>
</div>
<small><i>Code Review Run #f47bf0</i></small>
</div>
---
Should Bito avoid suggestions like this for future reviews? (<a
href=https://alpha.bito.ai/home/ai-agents/review-rules>Manage Rules</a>)
- [ ] Yes, avoid them
##########
superset/commands/dashboard/export.py:
##########
@@ -146,6 +146,27 @@ def _file_content(model: Dashboard) -> str:
if dataset:
target["datasetUuid"] = str(dataset.uuid)
+ # Replace display control dataset references with uuid.
+ # datasetId is intentionally preserved alongside datasetUuid so that
+ # bundles remain importable by older versions that do not yet
understand
+ # datasetUuid for display-control targets.
+ for customization in (
+ payload.get("metadata", {}).get("chart_customization_config") or []
+ ):
+ for target in customization.get("targets") or []:
+ dataset_id = target.get("datasetId")
+ if dataset_id is not None:
+ dataset = DatasetDAO.find_by_id(dataset_id)
+ if dataset:
+ target["datasetUuid"] = str(dataset.uuid)
+ else:
+ logger.warning(
+ "Dashboard '%s': display control target references
"
+ "missing dataset %s; datasetUuid will not be set",
+ model.dashboard_title,
+ dataset_id,
+ )
+
Review Comment:
<div>
<div id="suggestion">
<div id="issue"><b>Semantic duplication in dataset handling</b></div>
<div id="fix">
The added code for display controls duplicates logic from native filters in
both _file_content and _export methods. This introduces maintenance risk if one
section needs updates. Consider refactoring into a shared helper function.
</div>
</div>
<small><i>Code Review Run #f47bf0</i></small>
</div>
---
Should Bito avoid suggestions like this for future reviews? (<a
href=https://alpha.bito.ai/home/ai-agents/review-rules>Manage Rules</a>)
- [ ] Yes, avoid them
--
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]