From f8e04750714f950070a2303c697188aeb571c45e Mon Sep 17 00:00:00 2001 From: Andres Date: Tue, 22 Apr 2025 05:17:21 +0200 Subject: [PATCH] roll back some stuff changed for debugging purposes --- src/app/api/trpc/[trpc]/route.ts | 6 +---- .../[id]/_components/stream-card-client.tsx | 25 ++++++++----------- src/server/api/routers/history.ts | 5 +--- src/server/api/routers/leaderboard.ts | 4 +-- 4 files changed, 14 insertions(+), 26 deletions(-) diff --git a/src/app/api/trpc/[trpc]/route.ts b/src/app/api/trpc/[trpc]/route.ts index 428d4ab..c338ffa 100644 --- a/src/app/api/trpc/[trpc]/route.ts +++ b/src/app/api/trpc/[trpc]/route.ts @@ -30,9 +30,5 @@ const handler = (req: NextRequest) => } : undefined, }) -export const config = { - api: { - responseLimit: false, - }, -} + export { handler as GET, handler as POST } diff --git a/src/app/stream-card/[id]/_components/stream-card-client.tsx b/src/app/stream-card/[id]/_components/stream-card-client.tsx index a347026..b4675a1 100644 --- a/src/app/stream-card/[id]/_components/stream-card-client.tsx +++ b/src/app/stream-card/[id]/_components/stream-card-client.tsx @@ -11,26 +11,23 @@ export function StreamCardClient() { return null } - const gamesQuery = api.history.user_games.useQuery({ user_id: id }) - const gamesQueryResult = gamesQuery.data + const [gamesQueryResult, gamesQuery] = + api.history.user_games.useSuspenseQuery({ user_id: id }) const games = gamesQueryResult || [] // Ensure games is always an array - const rankedUserQuery = api.leaderboard.get_user_rank.useQuery({ - channel_id: RANKED_CHANNEL, - user_id: id, - }) - const rankedUserRank = rankedUserQuery.data + const [rankedUserRank, rankedUserQuery] = + api.leaderboard.get_user_rank.useSuspenseQuery({ + channel_id: RANKED_CHANNEL, + user_id: id, + }) + useEffect(() => { const interval = setInterval(async () => { - try { - await Promise.all([gamesQuery.refetch(), rankedUserQuery.refetch()]) - } catch (e) { - console.error('refetch failed:', e) - } - }, 1000 * 30) + await Promise.all([gamesQuery.refetch(), rankedUserQuery.refetch()]) + }, 1000 * 60) return () => clearInterval(interval) - }, [gamesQuery, rankedUserQuery]) + }, []) if (!rankedUserRank || !games?.length) { return null diff --git a/src/server/api/routers/history.ts b/src/server/api/routers/history.ts index 2e73152..881543a 100644 --- a/src/server/api/routers/history.ts +++ b/src/server/api/routers/history.ts @@ -14,14 +14,11 @@ export const history_router = createTRPCRouter({ }) ) .query(async ({ ctx, input }) => { - const res = await ctx.db + return await ctx.db .select() .from(player_games) .where(eq(player_games.playerId, input.user_id)) .orderBy(desc(player_games.gameNum)) - - console.log('history.user_games', res) - return res }), sync: publicProcedure.mutation(async () => { return syncHistory() diff --git a/src/server/api/routers/leaderboard.ts b/src/server/api/routers/leaderboard.ts index 4604278..df88463 100644 --- a/src/server/api/routers/leaderboard.ts +++ b/src/server/api/routers/leaderboard.ts @@ -24,8 +24,6 @@ export const leaderboard_router = createTRPCRouter({ }) ) .query(async ({ input }) => { - const res = await service.getUserRank(input.channel_id, input.user_id) - console.log('leaderboard.get_user_rank', res) - return res + return await service.getUserRank(input.channel_id, input.user_id) }), })