From ca8dd5a7026f2f3d3b02ca5ce61db076d7886d3c 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 10:29:57 -0600 Subject: [PATCH] fix: no existing cache overwrites for neighbors --- src/app/tools/ratings/page.tsx | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/app/tools/ratings/page.tsx b/src/app/tools/ratings/page.tsx index 365b77fc4..df0f09055 100644 --- a/src/app/tools/ratings/page.tsx +++ b/src/app/tools/ratings/page.tsx @@ -282,10 +282,14 @@ export default function Page() { usePlayersCache.setState( produce((draft: PlayersCache) => { neighbors.forEach((neighbor) => { - draft[region][season][neighbor.number - 1] = { - id: neighbor.spa_id, - score: neighbor.score, - } satisfies BlitzkriegRatingsLeaderboardEntry; + const position = neighbor.number - 1; + + if (!(position in draft[region][season])) { + draft[region][season][position] = { + id: neighbor.spa_id, + score: neighbor.score, + } satisfies BlitzkriegRatingsLeaderboardEntry; + } }); }), ); @@ -642,7 +646,7 @@ export default function Page() { }); cacheNeighbors( players[region][season][position].id, - ROWS_PER_PAGE * 3, + 4 * ROWS_PER_PAGE - 2, ); } } else {