From 9dd753a076a5ab12e359639bfa033098fafb6535 Mon Sep 17 00:00:00 2001 From: Keith Stevens Date: Mon, 16 Jan 2023 14:57:19 +0900 Subject: [PATCH 1/3] ensure we include a timeframe when fetching leaderboard --- website/src/pages/api/leaderboard.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/src/pages/api/leaderboard.ts b/website/src/pages/api/leaderboard.ts index 10a9a3a7..592f3da5 100644 --- a/website/src/pages/api/leaderboard.ts +++ b/website/src/pages/api/leaderboard.ts @@ -6,7 +6,7 @@ import { LeaderboardTimeFrame } from "src/types/Leaderboard"; * Returns the set of valid labels that can be applied to messages. */ const handler = withoutRole("banned", async (req, res) => { - const time_frame = req.query.time_frame as LeaderboardTimeFrame; + const time_frame = (req.query.time_frame as LeaderboardTimeFrame) || LeaderboardTimeFrame.day; const { leaderboard } = await oasstApiClient.fetch_leaderboard(time_frame); res.status(200).json(leaderboard); }); From 2d8778c299b3c9b02ee170124a5317d32633ffe6 Mon Sep 17 00:00:00 2001 From: Keith Stevens Date: Mon, 16 Jan 2023 16:03:34 +0900 Subject: [PATCH 2/3] Updating LeaderboardTable to use LeaderboardGridCell --- .../components/Dashboard/LeaderboardTable.tsx | 33 +++---------------- 1 file changed, 4 insertions(+), 29 deletions(-) diff --git a/website/src/components/Dashboard/LeaderboardTable.tsx b/website/src/components/Dashboard/LeaderboardTable.tsx index b6048f3f..f5d63cd9 100644 --- a/website/src/components/Dashboard/LeaderboardTable.tsx +++ b/website/src/components/Dashboard/LeaderboardTable.tsx @@ -1,17 +1,15 @@ -import { Box, Link, Stack, StackDivider, Text, useColorModeValue } from "@chakra-ui/react"; +import { Box, Link, Text, useColorModeValue } from "@chakra-ui/react"; import NextLink from "next/link"; -import { get } from "src/lib/api"; -import useSWR from "swr"; +import { LeaderboardGridCell } from "src/components/LeaderboardGridCell"; export function LeaderboardTable() { const backgroundColor = useColorModeValue("white", "gray.700"); const accentColor = useColorModeValue("gray.200", "gray.900"); - const { data: leaderboardEntries } = useSWR("/api/leaderboard", get); return (
- Top 5 Contributors + Top 5 Contributors Today View All -> @@ -25,30 +23,7 @@ export function LeaderboardTable() { borderRadius="xl" className="p-6 shadow-sm" > - } spacing="4"> -
-

Name

-
-

Score

-
-
- {leaderboardEntries?.map(({ display_name, score }, idx) => ( -
-
- {/* - Profile Picture - */} -

{display_name}

- {/* - {item.streakCount} - */} -
- -

{score}

-
-
- ))} -
+
From 8586eff5967536a8344cc44ad6326f846101e313 Mon Sep 17 00:00:00 2001 From: Keith Stevens Date: Mon, 16 Jan 2023 16:13:56 +0900 Subject: [PATCH 3/3] Using the proper type --- website/src/components/Dashboard/LeaderboardTable.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/website/src/components/Dashboard/LeaderboardTable.tsx b/website/src/components/Dashboard/LeaderboardTable.tsx index f5d63cd9..52cf762b 100644 --- a/website/src/components/Dashboard/LeaderboardTable.tsx +++ b/website/src/components/Dashboard/LeaderboardTable.tsx @@ -1,6 +1,7 @@ import { Box, Link, Text, useColorModeValue } from "@chakra-ui/react"; import NextLink from "next/link"; import { LeaderboardGridCell } from "src/components/LeaderboardGridCell"; +import { LeaderboardTimeFrame } from "src/types/Leaderboard"; export function LeaderboardTable() { const backgroundColor = useColorModeValue("white", "gray.700"); @@ -23,7 +24,7 @@ export function LeaderboardTable() { borderRadius="xl" className="p-6 shadow-sm" > - +