Skip to content

fix: compute StatCard trend from history data instead of hardcoded literals (#92) - #167

Open
rafaio1 wants to merge 1 commit into
MergeFi:mainfrom
rafaio1:fix/92-statcard-trend-hardcoded
Open

fix: compute StatCard trend from history data instead of hardcoded literals (#92)#167
rafaio1 wants to merge 1 commit into
MergeFi:mainfrom
rafaio1:fix/92-statcard-trend-hardcoded

Conversation

@rafaio1

@rafaio1 rafaio1 commented Aug 20, 2026

Copy link
Copy Markdown

Fixes #92.

  • Add computeTrend(history) helper to utils.ts that computes week-over-week percentage change from the last two data points, returning undefined when fewer than 2 points exist or the prior value is zero (avoiding division-by-zero and meaningless trends).
  • Replace all three hardcoded trend literals (12, 8, 18) in contributor and sponsor dashboards with computeTrend() calls against the same history arrays already passed as sparklines (contributorEarningsHistory, contributorSparkline, sponsorSpendHistory).
  • Trend now correctly renders negative values with the down-arrow/rose styling when the most recent period is lower than the prior — a path previously unexercised since all literals were positive.
  • When live backend history data becomes available (per Dashboard charts, activity feeds, and spend-by-repo panels are permanently hardcoded mock data, regardless of the Live data badge #73), these call sites will naturally compute from real data by swapping the mock array for the live one — no structural change needed.
  • TypeScript compiles cleanly with npx tsc --noEmit.

@vercel

vercel Bot commented Aug 20, 2026

Copy link
Copy Markdown

Someone is attempting to deploy a commit to the chonilius' projects Team on Vercel.

A member of the Team first needs to authorize it.

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.

Dashboard StatCard trend percentages are hardcoded literals, not computed from any real data

1 participant