Skip to content

fix(reports): export what is on screen instead of the last saved report - #59

Merged
Morialkar merged 1 commit into
mainfrom
fix/reports-live-exports
Aug 1, 2026
Merged

fix(reports): export what is on screen instead of the last saved report#59
Morialkar merged 1 commit into
mainfrom
fix/reports-live-exports

Conversation

@Morialkar

Copy link
Copy Markdown
Owner

Fixes defect (b) from manual QA, and with it the "two exports come out identical" symptom.

The bug

handleExportCsv and handleExportPdf each built a query AST and a layout from the live editor state — and then threw them away whenever a saved report was selected, calling GET /reports/{id}/export/csv|pdf, which re-runs the stored report.

The on-screen preview does the opposite: it posts the live state to /reports/preview. So the two disagreed:

  • changing columns, sorting or grouping updated the preview but produced a byte-identical export (the reported X == Y)
  • the configuration had to be saved before it could be exported at all

The change

Exports now always post the live state to the preview endpoints, so a downloaded file matches the preview it was requested from. The client keeps the report name for the filename, since those endpoints answer with a generic rapport_apercu.*.

The query AST and layout are now built once and shared by the preview, the save payload and both exports — they were duplicated in four places, which is how they drifted apart.

Verification

Driven against the running stack. With a saved report selected whose stored select is ["Nom Complet"], and Prénom ticked on screen without saving:

Path CSV header
old — GET /reports/{id}/export/csv "Nom Complet"
new — POST /reports/preview/csv "Nom Complet",Prénom

The network log confirms the click now issues POST /api/v1/reports/preview/csv while a report is selected.

Also: 65/65 client tests (2 new, asserting both exports POST the live configuration with a saved report selected), tsc -b, ESLint, Prettier.

Note

ReportBuilderPage is now exported so it can be rendered in tests; the route itself is unchanged.

Both export handlers built a query AST and layout from the live editor state,
then discarded them whenever a saved report was selected and called
GET /reports/{id}/export/... instead, which re-runs the stored report.

The on-screen preview meanwhile posts the live state to /reports/preview, so
the two disagreed: changing columns, sorting or grouping updated the preview
but produced a byte-identical export, and the configuration had to be saved
before it could be exported at all.

Exports now always post the live state to the preview endpoints, so the file
matches the preview it was requested from. The client keeps the report name
for the downloaded filename, since those endpoints answer with a generic one.

The query AST and layout are now built once and shared by the preview, the
save payload and both exports, so they cannot drift apart again.
@Morialkar
Morialkar merged commit 18c98ee into main Aug 1, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant