From ef9f3bd3611dd8fce0d7eaf287e1271edda2d172 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tr=C3=A8sAbhi?= <43380238+tresabhi@users.noreply.github.com> Date: Tue, 14 Nov 2023 13:07:17 -0600 Subject: [PATCH] feat: rewards --- .../ratings/current/league/[league]/route.ts | 2 +- src/app/tools/ratings/page.tsx | 44 +++++++++++++++---- 2 files changed, 37 insertions(+), 9 deletions(-) diff --git a/src/app/api/[region]/ratings/current/league/[league]/route.ts b/src/app/api/[region]/ratings/current/league/[league]/route.ts index 4e2b57735..9871416e4 100644 --- a/src/app/api/[region]/ratings/current/league/[league]/route.ts +++ b/src/app/api/[region]/ratings/current/league/[league]/route.ts @@ -7,6 +7,6 @@ export async function GET( { params }: { params: { region: Region; league: number } }, ) { return NextResponse.json( - await getRatingsLeague(params.region, params.league), + await getRatingsLeague(params.region, params.league, true), ); } diff --git a/src/app/tools/ratings/page.tsx b/src/app/tools/ratings/page.tsx index dc7d320e2..be0232178 100644 --- a/src/app/tools/ratings/page.tsx +++ b/src/app/tools/ratings/page.tsx @@ -38,7 +38,7 @@ import { getArchivedRatingsLeaderboard } from '../../../core/blitzkrieg/getArchi import { theme } from '../../../stitches.config'; import { PageTurner } from './components/PageTurner'; -const ROWS_PER_PAGE = 30; +const ROWS_PER_PAGE = Math.floor(100 / 3); const SEEDING_SIZE = 2 ** 7; interface NameCacheEntry { @@ -906,6 +906,7 @@ export default function Page() { Position Player + Reward Percentile @@ -922,12 +923,22 @@ export default function Page() { ).map((index) => { const id = players[region][season]?.[index]?.id; const clan = id ? names[region][id]?.clan : undefined; + const position = index + 1; const highlight = highlightedPlayer ? highlightedPlayer.type === 'id' ? highlightedPlayer.id === id : highlightedPlayer.position === index : false; - const row = ( + const reward = + !ratingsInfo?.detail && ratingsInfo?.rewards + ? ratingsInfo.rewards.find( + (reward) => + reward.from_position <= position && + reward.to_position >= position, + ) + : undefined; + + return ( - - {(index + 1).toLocaleString()}. - + {position.toLocaleString()}. {names[region][id] === null ? `Deleted player ${id}` : names[region][id]?.nickname ?? `Loading player...`} {clan ? ` [${clan}]` : ''} - + + {reward ? ( + + + {reward.count === 1 ? '' : `x${reward.count}`} + + ) : ( + '--' + )} + + {totalPlayers ? Math.ceil(((index + 1) / totalPlayers) * 100) : '--'} @@ -960,8 +990,6 @@ export default function Page() { ); - - return row; })}