feat: add server-side pagination to leaderboard page (#637)#703
feat: add server-side pagination to leaderboard page (#637)#703Shiva210Jyoti wants to merge 7 commits into
Conversation
…o fix/leaderboard-rate-limit-419
|
@Shiva210Jyoti is attempting to deploy a commit to the codersogs-3057's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
Hey @jakharmonika364 @Ayush-Patel-56, PR #703 is ready for review! All acceptance criteria covered, build clean. Please take a look 🙏 |
| * Server-side paginated global leaderboard ordered by XP descending. | ||
| * Uses OFFSET/LIMIT (Drizzle equivalent of Prisma skip/take). | ||
| * Global rank = (page - 1) * pageSize + index + 1. | ||
| */ | ||
| export async function getLeaderboardPage( | ||
| page: number, | ||
| pageSize: number = DEFAULT_PAGE_SIZE, |
There was a problem hiding this comment.
order by xp desc has no tiebreaker, so ties (very common at low xp) aren't stable across separate page loads - a contributor can show up on two pages or vanish from all of them. add order by xp desc, id asc.
also this bypasses getLeaderboard entirely for the global scope, so it has no rate limit (see #688) and no cache, unlike the sibling it duplicates. and rank here is row position, not dense_rank like every other scope uses, so tied users get different ranks.
Resolves #637
Summary
Implements server-side pagination for the leaderboard page using Drizzle ORM with raw SQL
OFFSET/LIMITqueries.Changes
src/app/actions/getLeaderboardPage.ts(new)getLeaderboardPage(page, pageSize = 20)LIMIT/OFFSET{ entries, totalCount, page, pageSize }(page - 1) * pageSize + index + 1src/app/(app)/leaderboard/page.tsxpagefromsearchParams(Next.js server component, no client state)getLeaderboardPage, other scopes use existinggetLeaderboardsrc/app/(app)/leaderboard/leaderboard-content.tsx{N} CONTRIBUTORSabove the tableentry.userId === currentUserId<Link href="?page=n">matching Issues page pagination styleAcceptance Criteria
?page=nNotes
skip/takeequivalenttsc --noEmitclean on leaderboard files