Commit Graph

9 Commits

Author SHA1 Message Date
Seid Muhammed affdcb35ff fix(studio): sum numeric-string columns in cumulative SQL charts (#47378)
Fixes: #47377

## What is the current behavior?

Enabling **Cumulative** on a results chart concatenates Y-axis values
instead
of summing them whenever the column is a `bigint`, `numeric`, `money`,
or
`count(*)` aggregate — which Postgres returns as JSON strings. For
per-row
values `10, 20, 30` the chart plots `10, 1020, 102030`.

`getCumulativeResults` ran `(prev[yKey] || 0) + row[yKey]` on raw result
rows.
The Y-axis selector explicitly allows numeric-string columns, so this is
a
common, fully-supported path (e.g. any `count(*) ... group by`).

## What is the new behavior?

Both operands are coerced with `Number()` before the addition, keeping
the
existing `|| 0` fallback for null/undefined/non-numeric values. The
series now
sums correctly: `10, 30, 60`.

The cumulative logic was previously duplicated in `ChartConfig.tsx` and
`QueryBlock.utils.ts` (which is how this bug slipped in twice). It is
now a
single shared, tested helper: `getCumulativeResults` lives in
`QueryBlock.utils.ts`, and `ChartConfig.tsx` imports it instead of
re-declaring
its own copy. The shared helper's `ChartConfig` type import is `import
type` to
avoid a runtime circular dependency, and its signature accepts
`readonly` rows
so both call sites type-check.

## Additional context

- Added regression tests for numeric-string inputs and for
null/undefined/non-numeric fallback to `0`. The existing tests only
covered
literal `number` inputs, never the string form Postgres actually
returns.
- Verified the new tests fail against the old code (`y: '010'`,
`'05undefined'`)
and pass with the fix. Full `QueryBlock.utils.test.ts` suite: 18
passing.

No migrations, no API changes, no infra changes.


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

* **Bug Fixes**
* Fixed cumulative chart calculations so numeric values are always added
correctly, even when results arrive as strings.
* Improved handling of empty or non-numeric values in cumulative totals
so they are treated as zero instead of breaking the sum.

* **Tests**
* Added coverage for cumulative result calculations with numeric strings
and missing values.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2026-06-29 14:53:24 +00:00
Charis 205cbe7d26 chore(studio}: enforce import order, remove bare import specifiers (#44585) 2026-04-07 20:34:10 -04:00
Jordi Enric 785625c92f fix: add compact formatting to Y axis numbers in db charts (#43170)
In the db charts, numbers in the Y axis are not formatted, sometimes
these get too big and get cut-off.

## before
(in this example it is not cutoff because the number is not big enough)
<img width="1020" height="634" alt="CleanShot 2026-02-25 at 11 20 35@2x"
src="https://github.com/user-attachments/assets/bc29edcc-331f-44d1-934f-1553b895c338"
/>

## after
<img width="936" height="676" alt="CleanShot 2026-02-25 at 11 21 07@2x"
src="https://github.com/user-attachments/assets/eae4ea4c-b8cd-4fe4-a361-9b029955217b"
/>
2026-02-25 18:42:17 +01:00
Jordi Enric a36c50ad88 add logarithmic option to custom reports (#43001)
https://linear.app/supabase/issue/FE-2595/dashboard-feedback-logarithmic-scale-option-for-custom-report-charts#comment-19c2f27a

- adds logarithmic view option to charts
<img width="1308" height="866" alt="CleanShot 2026-02-18 at 21 15 56@2x"
src="https://github.com/user-attachments/assets/2ed95d0e-ccd0-4cd1-9a3b-ac9ae5628995"
/>
2026-02-19 07:20:12 -07:00
Jordi Enric eb85515acb minor percentage formatting fixes (#41923)
* support total percentage normalization and show idle time in cpu usage chart

* pretier

* improve test

* clarify in comment why new prop is necessary

* fix type error int est

* refactor to use max value instead of idle property, add more tests

* cleanup composed chart

* prettier

* fix tests

* react improvements

* remove unused stacking properties

* remove rest property references as it wont be used

* fix comment and max cpu desc

* test the resolvehighlightedvalue function

* undo unnecessary composedcharthandler change

* remove unnecessary comment

* minor db charts percentage formatting fixes

* move format check

* fix issue with conflict resolution
2026-01-27 13:07:39 +00:00
Jordi Enric aec9be147a chart: handle values below 0.01 (#41742)
* fix

* fix file
2026-01-06 17:29:29 +00:00
Ivan Vasilov cb1e3a8170 chore: Prep work for pnpm (#29610)
* Add all missing libraries in the packages/apps.

* Add all missing Vitest imports to the tests.

* Add some missing exports to ui.

* Fix the admonition export.

* Fix various minor bugs.

* Migrate the ui package to use vitest.
2024-10-01 11:29:37 +02:00
Kyle Rummens 523f241067 Fix/#21742 format stats chart numbers (#21760)
fix: format numbers in statistics charts on hover
2024-03-05 15:11:17 +00:00
Ivan Vasilov 436bdb10ae chore: Move the studio app to apps/studio (#18915)
* Move all studio files from /studio to /apps/studio.

* Move studio specific prettier ignores.

* Fix the ui references from studio.

* Fix the css imports.

* Fix all package.json issues.

* Fix the prettier setup for the studio app.

* Add .turbo folder to prettierignore.

* Fix the github workflows.
2023-11-15 12:38:55 +01:00