From c71ababd5bbc7ab31f9f74eb2794e4cd04ba8d08 Mon Sep 17 00:00:00 2001 From: Pinapelz Date: Tue, 4 Nov 2025 18:35:54 -0800 Subject: add recently played games to profile page --- backend/src/routes/score.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'backend/src/routes/score.ts') diff --git a/backend/src/routes/score.ts b/backend/src/routes/score.ts index a652b93..168629a 100644 --- a/backend/src/routes/score.ts +++ b/backend/src/routes/score.ts @@ -181,6 +181,7 @@ export const handleGetScores = async ( if (!userId || !internalGameName || !pageNum) { return res.status(400).json({ error: "Missing required parameters" }); } + const pageNumber = parseInt(pageNum as string); const gameInternalName = internalGameName as string; const userIdNumber = parseInt(userId as string); @@ -200,6 +201,15 @@ export const handleGetScores = async ( let scores; let totalScores; + const user = await prisma.user.findUnique({ + where: { id: userIdNumber }, + select: { username: true }, + }); + + if (!user) { + return res.status(404).json({ error: "User not found" }); + } + if (pbOnlyFlag) { // For pbOnly, we need to get the best score for each chart if (sortKeyString === "timestamp") { @@ -359,6 +369,7 @@ export const handleGetScores = async ( res.status(200).json({ scores: safeScores, num_pages, + user: user.username }); } catch (error) { console.error("Failed to fetch scores:", error); -- cgit v1.2.3