From 480ad663767afb5d9ffeaf571dff88bad0d4e998 Mon Sep 17 00:00:00 2001 From: Mike Johnston Date: Fri, 30 Jan 2026 17:53:55 -0500 Subject: [PATCH] more qol --- backend/src/routes/friends.js | 5 +++-- frontend/src/pages/Friends.jsx | 6 +++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/backend/src/routes/friends.js b/backend/src/routes/friends.js index 9842778..4c7aea8 100644 --- a/backend/src/routes/friends.js +++ b/backend/src/routes/friends.js @@ -59,7 +59,8 @@ router.get('/', authMiddleware, asyncHandler(async (req, res) => { const challengeFriends = await query( `SELECT DISTINCT u.id, u.username, u.email, - (SELECT COUNT(*) FROM predictions WHERE user_id = u.id AND status = 'validated') as total_points + (SELECT COUNT(*) FROM predictions WHERE user_id = u.id AND status = 'validated') as total_points, + (SELECT status FROM friendships WHERE (user_id = ? AND friend_id = u.id) OR (user_id = u.id AND friend_id = ?) LIMIT 1) as friendship_status FROM users u WHERE u.id IN ( SELECT DISTINCT cp.user_id @@ -79,7 +80,7 @@ router.get('/', authMiddleware, asyncHandler(async (req, res) => { ) ${notInClause} ORDER BY u.username`, - [req.user.userId, req.user.userId, req.user.userId, req.user.userId, req.user.userId, req.user.userId, ...friends.map(f => f.id)] + [req.user.userId, req.user.userId, req.user.userId, req.user.userId, req.user.userId, req.user.userId, req.user.userId, req.user.userId, ...friends.map(f => f.id)] ); res.json({ diff --git a/frontend/src/pages/Friends.jsx b/frontend/src/pages/Friends.jsx index 793a084..b927e80 100644 --- a/frontend/src/pages/Friends.jsx +++ b/frontend/src/pages/Friends.jsx @@ -281,12 +281,12 @@ export default function Friends() {
{friend.total_points} points