perf: memoize leaderboard badge tiers - #891
Conversation
|
@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! 🚀 |
|
Auto-review failed (API error). Leaving PR for human review. |
|
Auto-review failed (API error). Leaving PR for human review. |
| const parts = fullKey.split("."); | ||
| const key = parts[parts.length - 1]; | ||
| const namespace = parts.length > 1 ? parts[0] : ''; | ||
| const namespace = parts.length > 1 ? parts[0] : ""; |
|
Auto-review failed (API error). Leaving PR for human review. |
|
Auto-review failed (API error). Leaving PR for human review. |
|
Auto-review failed (API error). Leaving PR for human review. |
|
Auto-review failed (API error). Leaving PR for human review. |
|
Auto-review failed (API error). Leaving PR for human review. |
davidmaronio
left a comment
There was a problem hiding this comment.
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:
- 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.
- 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.
- .vscode/settings.json should not be added to the repo in a perf PR; please remove it.
- 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.
Summary
Verification
npm.cmd test -- --runInBand src/__tests__/components/ContributorLeaderboard.test.tsxnpx.cmd eslint src/components/ContributorLeaderboard.tsx src/lib/gamification.ts src/__tests__/components/ContributorLeaderboard.test.tsxnpx.cmd prettier --check ...git diff --checkNotes
Project-wide TypeScript checking is currently blocked by an existing missing
@web3auth/authmodule dependency.Closes #829