codeant-ai-for-open-source[bot] commented on code in PR #42485:
URL: https://github.com/apache/superset/pull/42485#discussion_r3717928693
##########
superset-frontend/src/hooks/apiResources/dashboards.ts:
##########
@@ -79,14 +79,7 @@ export const useDashboardDatasets = (idOrSlug: string |
number) =>
datasets =>
datasets.map(dataset => ({
...dataset,
- currencyFormats: Object.fromEntries(
- (dataset.metrics ?? [])
- .filter(metric => !!metric.currency)
- .map((metric): [string, Currency] => [
- metric.metric_name,
- metric.currency!,
- ]),
- ),
+ currencyFormats: getCurrencyFormats(dataset.metrics),
})),
Review Comment:
**Suggestion:** The currency lookup is derived only for the initial
`useDashboardDatasets` response. After dashboard metadata is saved,
`dashboardState.ts` independently refetches `/api/v1/dashboard/${id}/datasets`
and dispatches the raw result through `setDatasources`, replacing these
enriched objects and dropping `currencyFormats`. Reuse this transformation for
that refresh path or derive the lookup in `setDatasources` so dashboard charts
retain currency formatting after an in-SPA save. [incomplete implementation]
<details>
<summary><b>Severity Level:</b> Major ⚠️</summary>
```mdx
- ❌ Dashboard dataset refreshes discard currency formatting metadata.
- ⚠️ In-SPA dashboard saves can show stale currency formats.
- ⚠️ Full page reload is required to restore derived formats.
```
</details>
[](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt_id=934ad484fe8544a5a570a4984d4b7ecc&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
[](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt_id=934ad484fe8544a5a570a4984d4b7ecc&service=github&base_url=https%3A%2F%2Fgithub.com&org=apache&repo=apache%2Fsuperset)
*(Use Cmd/Ctrl + Click for best experience)*
<details>
<summary><b>Prompt for AI Agent 🤖 </b></summary>
```mdx
This is a comment left during a code review.
**Path:** superset-frontend/src/hooks/apiResources/dashboards.ts
**Line:** 79:83
**Comment:**
*Incomplete Implementation: The currency lookup is derived only for the
initial `useDashboardDatasets` response. After dashboard metadata is saved,
`dashboardState.ts` independently refetches `/api/v1/dashboard/${id}/datasets`
and dispatches the raw result through `setDatasources`, replacing these
enriched objects and dropping `currencyFormats`. Reuse this transformation for
that refresh path or derive the lookup in `setDatasources` so dashboard charts
retain currency formatting after an in-SPA save.
Validate the correctness of the flagged issue. If correct, How can I resolve
this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask
user if the user wants to fix the rest of the comments as well. if said yes,
then fetch all the comments validate the correctness and implement a minimal fix
```
</details>
<a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F42485&comment_hash=ff23ec43535a969759a1974e3ea4948a7eb73cc066d9c52dead39f7814e0ee3e&reaction=like'>👍</a>
| <a
href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F42485&comment_hash=ff23ec43535a969759a1974e3ea4948a7eb73cc066d9c52dead39f7814e0ee3e&reaction=dislike'>👎</a>
--
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]