Skip to content

perf: memoize leaderboard badge tiers - #891

Open
Anthony-19 wants to merge 8 commits into
Iris-IV:mainfrom
Anthony-19:feat/gamification-badge
Open

perf: memoize leaderboard badge tiers#891
Anthony-19 wants to merge 8 commits into
Iris-IV:mainfrom
Anthony-19:feat/gamification-badge

Conversation

@Anthony-19

Copy link
Copy Markdown
Contributor

Summary

  • Memoize each leaderboard contributor’s gamification profile by contribution total.
  • Add a stroop-based gamification helper without altering tier rules.
  • Add a regression test proving unchanged re-renders do not recalculate badge tiers.

Verification

  • npm.cmd test -- --runInBand src/__tests__/components/ContributorLeaderboard.test.tsx
  • npx.cmd eslint src/components/ContributorLeaderboard.tsx src/lib/gamification.ts src/__tests__/components/ContributorLeaderboard.test.tsx
  • npx.cmd prettier --check ...
  • git diff --check

Notes

Project-wide TypeScript checking is currently blocked by an existing missing @web3auth/auth module dependency.

Closes #829

@drips-wave

drips-wave Bot commented Jul 30, 2026

Copy link
Copy Markdown

@Anthony-19 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@sshdopey

Copy link
Copy Markdown
Contributor

Auto-review failed (API error). Leaving PR for human review.

@sshdopey

Copy link
Copy Markdown
Contributor

Auto-review failed (API error). Leaving PR for human review.

Comment thread scripts/check-i18n.mjs
const parts = fullKey.split(".");
const key = parts[parts.length - 1];
const namespace = parts.length > 1 ? parts[0] : '';
const namespace = parts.length > 1 ? parts[0] : "";
@sshdopey

Copy link
Copy Markdown
Contributor

Auto-review failed (API error). Leaving PR for human review.

@sshdopey

Copy link
Copy Markdown
Contributor

Auto-review failed (API error). Leaving PR for human review.

@sshdopey

Copy link
Copy Markdown
Contributor

Auto-review failed (API error). Leaving PR for human review.

@sshdopey

Copy link
Copy Markdown
Contributor

Auto-review failed (API error). Leaving PR for human review.

@sshdopey

Copy link
Copy Markdown
Contributor

Auto-review failed (API error). Leaving PR for human review.

@davidmaronio davidmaronio left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the idea is right: calculateGamificationProfileFromStroops is a sensible helper that keeps tier rules in one place, and memoizing per-contributor profiles in the leaderboard plus a regression test that unchanged re-renders do not recalculate is exactly what #829 asked for.

but the PR cannot be merged in its current shape:

  1. the diff touches 30+ files that have nothing to do with the leaderboard (jest.config.ts, playwright.config.ts, i18n scripts, WalletContext, DonationContext, many unrelated tests, .vscode/settings.json) and github reports the branch as conflicting. it looks like the branch was cut from the broken pre-#875 main. please rebase onto current main and reduce the diff to ContributorLeaderboard.tsx, gamification.ts, and the new test.
  2. src/lib/gamification.ts: most of the file's hunks are quote-style reformatting (single to double quotes). formatting churn belongs to prettier on main, not this PR; after the rebase these hunks should disappear or be dropped.
  3. .vscode/settings.json should not be added to the repo in a perf PR; please remove it.
  4. src/lib/gamification.ts (calculateGamificationProfileFromStroops): Number(totalAmountStroops) loses precision above 2^53 stroops. unlikely in practice but a one-line comment or a clamp would document the assumption.

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.

[Performance] gamification.ts badge calculation runs on every ContributorLeaderboard render

4 participants