From c7995340095bd3453d5ef4e78adecbcf15266770 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:42:38 -0600 Subject: [PATCH] feat: position relative neighbor caching --- src/app/tools/ratings/page.tsx | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/app/tools/ratings/page.tsx b/src/app/tools/ratings/page.tsx index e367c7a9e..60bc17e71 100644 --- a/src/app/tools/ratings/page.tsx +++ b/src/app/tools/ratings/page.tsx @@ -277,12 +277,18 @@ export default function Page() { if (!isMissing) return []; } + const seedingPlayerPosition = parseInt( + Object.entries(players[region][season]).find( + ([, player]) => id === player.id, + )![0], + ); const { neighbors } = await getRatingsNeighbors(region, id, size, true); usePlayersCache.setState( produce((draft: PlayersCache) => { - neighbors.forEach((neighbor) => { - const position = neighbor.number - 1; + neighbors.forEach((neighbor, neighborIndex) => { + // const position = neighbor.number - 1; + const position = neighborIndex - radius + seedingPlayerPosition; if (!(position in draft[region][season])) { draft[region][season][position] = {