fix: Fix map data parsing for Superset and Spring Boot payload compat… - #282
Conversation
commit: |
There was a problem hiding this comment.
Pull request overview
This PR updates the map data transformation logic to better handle differing payload shapes from Superset vs Spring Boot APIs, improving measure parsing and label/value extraction so downstream map/chart components can consume consistent transformedData.
Changes:
- Make
measuresparsing resilient to arrays, CSV strings, JSON-array strings, and empty values (fallback to metadata measures). - Normalize label/value selection using metadata-aware helpers and add a fallback transformation path for flat aggregate Spring Boot responses (no
children). - Add a changeset bump for
@devgateway/dvz-ui-react.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| packages/dvz-ui/src/embeddable/map/MapDataFrame.jsx | Improves measure parsing and transforms Superset/Spring Boot payloads into consistent locationsData/nationalData. |
| .changeset/busy-spiders-pull.md | Patch changeset describing the map parsing compatibility fix. |
Suppressed comments (1)
packages/dvz-ui/src/embeddable/map/MapDataFrame.jsx:386
- The
if (item.children) { ... }block that manually buildsnewItem.childrenis immediately overwritten bynewItem.children = buildChildren(item, measure), so it has no effect and is misleading. Remove the redundant block (or fold the needed behavior intobuildChildren) to avoid dead code and inconsistent child shaping.
if (item.children) {
newItem.children = []
item.children.forEach(child => {
newItem.children.push({...child, label: child.value, value: getMeasureValue(child, measure)});
})
}
// Handle nested children (Superset format), at any dimension depth
newItem.children = buildChildren(item, measure);
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
commit: |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.
Suppressed comments (2)
Previously missed (1) — in code that hasn't changed since the last review.
packages/dvz-ui/src/embeddable/map/MapDataFrame.jsx:383
- The
if (item.children)block buildsnewItem.children(lines 378-383), but it is immediately overwritten bynewItem.children = buildChildren(item, measure)right after. This makes the loop dead code and adds unnecessary work/confusion. Remove the redundant block and keep a single children-normalization path (preferably the recursivebuildChildren).
This issue also appears on line 385 of the same file.
if (item.children) {
newItem.children = []
item.children.forEach(child => {
newItem.children.push({...child, label: child.value, value: getMeasureValue(child, measure)});
})
}
packages/dvz-ui/src/embeddable/map/MapDataFrame.jsx:387
- Nested breakdown rows come from
buildChildren(item, measure), butbuildChildrenstill setsvalue: child[measure]andlabel: child.value(see its implementation above). That bypasses the newgetMeasureValue/getLocationLabellogic and can produce incorrect tooltip breakdown values/labels for Superset-style payloads where the measure value isn't stored underchild[measure](or wherechild.valueis numeric). Align nested child normalization with the same value/label resolution used for top-level rows.
// Handle nested children (Superset format), at any dimension depth
newItem.children = buildChildren(item, measure);
…ibility## Description
Type of change
fix:)feat:)BREAKING CHANGE:)refactor:/chore:)docs:)Affected package(s)
@devgateway/dvz-ui-react@devgateway/wp-react-libexampleonly (no changeset needed)Checklist
pnpm changeset) for any change to a published packagepnpm buildpasses locallypnpm --filter @devgateway/* typecheckpasses