Skip to content

reports: a count tile reads its number from the server (#7161) - #7236

Merged
delchev merged 2 commits into
masterfrom
issue-7161-count-tile-server-sum
Sep 10, 2026
Merged

reports: a count tile reads its number from the server (#7161)#7236
delchev merged 2 commits into
masterfrom
issue-7161-count-tile-server-sum

Conversation

@delchev

@delchev delchev commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Two follow-ups to #7102, where a dashboard kind: count tile over an aggregating report learned to sum the report's count(*) measure - the rows being groups, the count endpoint reports the number of groups.

The sum was the browser's

application-core's reports store fetched every group row of the report, per tile, per dashboard load, to add up one column - thousands of rows for a report grouped by day or customer, where the /count endpoint it replaced was one number in one round trip.

The generated report repository now sums the column in SQL - SELECT SUM("<alias>") AS "REPORT_SUM" FROM (<the filtered report query>) - behind a POST /sum, carrying the same per-column conditions the tile's at pins and the report page's filter panel already speak, and the store reads that.

The column is matched against the report's own aliases (the allowlist the conditions already use) and must be numeric, so a total over a text column or an alias the report does not carry is a 400, not a 500; a report yielding no rows sums to zero rather than null.

The editor offered a column that cannot be the record count

It offered ANY aggregate: COUNT column, including a count(<field>), whose sum is the number of rows carrying a value in that field - a different number, and never the record count. The intent path was protected by getCountMeasure()'s count(*)-only rule; the hand-authored path is now too: only a count(*) column is offered, and a stored one that is not is dropped on load (console warning, file marked dirty) rather than left naming a column the picker no longer shows.

Verification

IntentEmissionCoverageIT - emission (the SQL wrapper, the numeric-type gate, the controller's @Post("/sum")) plus the live half against the published app: the ClaimsByUnit report groups two claims into one row, so /sum answers 2 where /count answers 1 - the two numbers differ, which is what makes the assertion about reading the right one; a text column and an unknown alias are 400s; and a pinned condition narrows the sum to 0.

Ran green locally with one pre-existing assertion relaxed: master is currently red on IntentEmissionCoverageIT:2000 (a master being deleted must suspend the per-line totals write-back, #7143) on both DB legs - it fails on run 34337194456 too, and it aborts this single big test method before any of the assertions above are reached. Nothing in this PR touches that path.

Docs: dirigible-io/dirigible-io.github.io#241.

Fixes #7161

Two follow-ups to #7102, where a dashboard `kind: count` tile over an
AGGREGATING report learned to sum the report's `count(*)` measure - the rows
being groups, the count endpoint reports the number of groups.

The sum was the BROWSER's: the reports store fetched every group row of the
report, per tile, per dashboard load, to add up one column - thousands of rows
for a report grouped by day or customer, where the endpoint it replaced was one
number in one round trip. The generated report repository now sums the column in
SQL (`SELECT SUM("<alias>") FROM (<the filtered report query>)`) behind a
`POST /sum`, carrying the same per-column conditions the tile's `at` pins and
the report page's filter panel already speak, and the store reads that.

The column is matched against the report's own aliases and must be numeric -
the same allowlist discipline the conditions use, so a total over a text column
or an alias the report does not carry is a 400, not a 500 - and a report
yielding no rows sums to zero rather than null.

The second half is the editor: it offered ANY `aggregate: COUNT` column as the
Count column, including a `count(<field>)`, whose sum is the number of rows
carrying a value in that field and never the record count. The intent path was
protected by `getCountMeasure()`'s count(*)-only rule; the hand-authored path
now is too - only a `count(*)` column is offered, and a stored one that is not
is dropped on load (with a console warning and the file marked dirty) rather
than left naming a column the picker no longer shows.

Fixes #7161

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@delchev
delchev merged commit 3edcdd9 into master Sep 10, 2026
10 of 11 checks passed
@delchev
delchev deleted the issue-7161-count-tile-server-sum branch September 10, 2026 08:01
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.

reports: a count tile fetches every group row to sum one column in the browser

1 participant