From 0834bc6ca5722c96ca1be55d93d780abc1d61ee8 Mon Sep 17 00:00:00 2001 From: "Kalle (Sendou)" <38327916+Sendouc@users.noreply.github.com> Date: Sun, 20 Dec 2020 14:28:06 +0200 Subject: [PATCH] leaderboards public ver --- hooks/sr.ts | 5 +++ pages/api/sr/records/index.ts | 3 -- pages/sr/leaderboards/index.tsx | 65 +++++++++++++++++++-------------- 3 files changed, 42 insertions(+), 31 deletions(-) diff --git a/hooks/sr.ts b/hooks/sr.ts index 9ef9f7c04..fcee04c7a 100644 --- a/hooks/sr.ts +++ b/hooks/sr.ts @@ -51,9 +51,14 @@ export function useSalmonRunRecords() { } ); + const userIds = new Set(); + const data = (recordsData ?? []).filter((record) => { if (record.rotation.stage !== state.stage) return false; if (record.category !== state.category) return false; + if (record.roster.every((user) => userIds.has(user.id))) return false; + + record.roster.forEach((user) => userIds.add(user.id)); return true; }); diff --git a/pages/api/sr/records/index.ts b/pages/api/sr/records/index.ts index c8068bfca..66b1f53cf 100644 --- a/pages/api/sr/records/index.ts +++ b/pages/api/sr/records/index.ts @@ -21,9 +21,6 @@ const postHandler = async (req: NextApiRequest, res: NextApiResponse) => { const user = await getMySession(req); if (!user) return res.status(401).end(); - if (!SALMON_RUN_ADMIN_DISCORD_IDS.includes(user.discordId)) { - return res.status(401).end(); - } const parsed = salmonRunRecordSchema.safeParse(req.body); if (!parsed.success) { diff --git a/pages/sr/leaderboards/index.tsx b/pages/sr/leaderboards/index.tsx index 7ade1dcdc..258c55e79 100644 --- a/pages/sr/leaderboards/index.tsx +++ b/pages/sr/leaderboards/index.tsx @@ -110,7 +110,7 @@ const SalmonRunLeaderboardsPage = ({}) => { - + { aria-label="Golden eggs count" /> - + Weapons - + Players - + Rotation Dates - + Links @@ -143,11 +143,11 @@ const SalmonRunLeaderboardsPage = ({}) => { return ( {getRankingString(placement)} - + {record.goldenEggCount} - + {record.rotation.weapons.map((wpn) => ( @@ -158,7 +158,12 @@ const SalmonRunLeaderboardsPage = ({}) => { {record.roster.map((user) => ( - + {user.username}#{user.discriminator} @@ -166,28 +171,32 @@ const SalmonRunLeaderboardsPage = ({}) => { - - {new Date( - record.rotation.startTime - ).toLocaleDateString()} - - - - - {new Date(record.rotation.endTime).toLocaleDateString()} - + + + {new Date( + record.rotation.startTime + ).toLocaleDateString()} + + - + + {new Date( + record.rotation.endTime + ).toLocaleDateString()} + + - + {record.links.map((link) => (