fix(plugin-chart-ag-grid-table): show correct percent-metric totals in summary row#41247
fix(plugin-chart-ag-grid-table): show correct percent-metric totals in summary row#41247kgabryje wants to merge 2 commits into
Conversation
…n summary row When a metric is added to Percentage Metrics and Show Summary (show_totals) is enabled, the totals/footer row rendered 0.000% in the percentage column. The totals query hardcoded post_processing: [], so its response was keyed `metric` instead of the `%metric` key the footer looks up. Capture the percent-metric `contribution` rule from the main query and reapply only that rule to the totals query's post_processing, so the single aggregated totals row exposes `%metric` keys (value/value = 100%). The main query's time-comparison operator is deliberately not carried over to the single-row totals query. The classic plugin-chart-table had the identical bug and is fixed symmetrically (default row_limit calculation mode). Fixes apache#37627 Signed-off-by: Kamil Gabryjelski <kamil.gabryjelski@gmail.com>
Code Review Agent Run #bd4ebaActionable Suggestions - 0Review Details
Bito Usage GuideCommands Type the following command in the pull request comment and save the comment.
Refer to the documentation for additional commands. Configuration This repository uses Documentation & Help |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #41247 +/- ##
==========================================
+ Coverage 64.36% 64.37% +0.01%
==========================================
Files 2651 2651
Lines 144812 144812
Branches 33417 33417
==========================================
+ Hits 93208 93227 +19
+ Misses 49935 49916 -19
Partials 1669 1669
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Mirror the ag-grid regression test: with a time comparison active alongside percent metrics and show_totals, the classic table's totals query must carry the percent-metric contribution op but not the time-comparison operator. Signed-off-by: Kamil Gabryjelski <kamil.gabryjelski@gmail.com>
Code Review Agent Run #e992aeActionable Suggestions - 0Review Details
Bito Usage GuideCommands Type the following command in the pull request comment and save the comment.
Refer to the documentation for additional commands. Configuration This repository uses Documentation & Help |
SUMMARY
In the Interactive Table (Table V2 /
plugin-chart-ag-grid-table) and the classic Table (plugin-chart-table) charts, when a metric is added to the Percentage Metrics control and Show Summary (show_totals) is enabled, the summary/totals (footer) row rendered0.000%in every percentage column. Regular data rows were correct — only the totals row was wrong.Root cause: The main query builds a
contributionpost-processing operation that renames percent-metric columnsmetric→%metric, andtransformProps(and the footer cell) looks values up by the%-prefixed key. The separate totals query (built whenshow_totals+ aggregate query mode) hardcodedpost_processing: [], so its response was keyedmetricinstead of%metric. The footer lookup missed and fell back to0.000%.Fix: Capture the percent-metric
contributionrule when building the main query and reapply only that rule to the totals query'spost_processing. Runningcontributionon the single aggregated totals row yields value/value = 100% per percent column, so the footer now shows100.000%(the sum of all rows' percentage contributions). The main query's time-comparison operator is deliberately not carried over — it must not run against the single-row totals query.Both the AG-Grid plugin and the classic table plugin had the identical
post_processing: []bug and both are fixed symmetrically.KNOWN LIMITATION / FOLLOW-UP
This PR fixes the percent-metric summary/footer for:
plugin-chart-ag-grid-table) — the chart reported in Percentage metrics column display only zero value #37627, andplugin-chart-table) in its defaultpercent_metric_calculation = 'row_limit'mode.It does not fix the classic Table in the non-default
percent_metric_calculation = 'all_records'mode whenshow_totalsis also enabled. That case is a separate, pre-existing bug with a different root cause: inall_recordsmode an extra all-records query is appended, andtransformPropsreads the footer percent from that query by fixed position (queriesData[1]/[2]), not from the dedicated totals query this PR corrects. Properly wiring the footer forall_recordsmode requires changes to the positional query indexing intransformPropsand is left for a follow-up. This PR does not regress that mode.BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
TESTING INSTRUCTIONS
100.000%instead of0.000%.Automated tests (jest) were added in both plugins'
test/buildQuery.test.ts:should reapply percent-metric contribution op to totals query,should omit time-comparison op from totals post_processing,should leave totals post_processing empty without percent metricsshould reapply contribution op to totals query in row_limit mode,should omit time-comparison op from totals post_processing,should leave totals post_processing empty without percent metricsADDITIONAL INFORMATION