Skip to content

Fix: stat cards render 24h counts as percentages - #9

Open
mpont91 wants to merge 1 commit into
ent0n29:mainfrom
mpont91:fix/statscard-trend-units
Open

Fix: stat cards render 24h counts as percentages#9
mpont91 wants to merge 1 commit into
ent0n29:mainfrom
mpont91:fix/statscard-trend-units

Conversation

@mpont91

@mpont91 mpont91 commented Aug 26, 2026

Copy link
Copy Markdown

The dashboard stat cards show things like "+10500% vs last period".

That number is not a percentage and there is no previous period. /api/stats returns plain counts:

countIf(ts >= now() - INTERVAL 1 DAY)              AS trades_24h,
uniqExactIf(proxy_address, ts >= now() - INTERVAL 1 DAY) AS traders_24h

and page.tsx passes them straight through:

trend={displayStats.trades_24h > 0 ? { value: displayStats.trades_24h, isPositive: true } : undefined}

while StatsCard appends a % and the caption "vs last period":

{trend.isPositive ? "+" : ""}{trend.value}%
...
<span>vs last period</span>

So 10,500 trades in the last day renders as "+10500%". On a fresh deployment the API makes it obvious — total_trades and trades_24h come back identical, which no percentage change could be:

{ "total_trades": 10500, "trades_24h": 10500 }

Adds isPercentage (off by default, so a count stays a count) and an optional label, and has the two call sites say "in the last 24h". Values are thousands-separated while we are here.

The component keeps rendering a real percentage the moment someone passes isPercentage: true, so nothing is lost if period-over-period comparison gets added later.

tsc --noEmit clean.

The dashboard passes traders_24h and trades_24h to StatsCard, which appends a
% sign and labels it "vs last period". Both are plain counts from
countIf(ts >= now() - INTERVAL 1 DAY), and nothing in the code compares two
periods, so the card reads "+10500%" for what is really 10,500 trades today.

Adds isPercentage (off by default) and an optional label, and has the two call
sites say "in the last 24h". Values are also thousands-separated.
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