aboutsummaryrefslogtreecommitdiffstats
path: root/backend/src/routes/score.ts
diff options
context:
space:
mode:
authorPinapelz <yukais@pinapelz.com>2025-11-04 18:35:54 -0800
committerPinapelz <yukais@pinapelz.com>2025-11-04 18:35:54 -0800
commitc71ababd5bbc7ab31f9f74eb2794e4cd04ba8d08 (patch)
tree7caba0aab623b8e552c5841639e2fb3b4d365be2 /backend/src/routes/score.ts
parentf3f8eaca7a7340cf268405c1f95ea38806ad23ad (diff)
add recently played games to profile page
Diffstat (limited to 'backend/src/routes/score.ts')
-rw-r--r--backend/src/routes/score.ts11
1 files changed, 11 insertions, 0 deletions
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);
send patches to the email below
yukais@pinapelz.com
include the subject [PATCH repo_name]
pinapelz.com
homepage