Fix: stat cards render 24h counts as percentages - #9
Open
mpont91 wants to merge 1 commit into
Open
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The dashboard stat cards show things like "+10500% vs last period".
That number is not a percentage and there is no previous period.
/api/statsreturns plain counts:and
page.tsxpasses them straight through:while
StatsCardappends a%and the caption "vs last period":So 10,500 trades in the last day renders as "+10500%". On a fresh deployment the API makes it obvious —
total_tradesandtrades_24hcome 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 optionallabel, 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 --noEmitclean.