friend bugfix
All checks were successful
Build Images and Deploy / Update-PROD-Stack (push) Successful in 34s
All checks were successful
Build Images and Deploy / Update-PROD-Stack (push) Successful in 34s
This commit is contained in:
@@ -45,6 +45,11 @@ router.get('/', authMiddleware, asyncHandler(async (req, res) => {
|
||||
);
|
||||
|
||||
// Also get people who have shared challenges with me (auto-friends from challenges)
|
||||
// Build the NOT IN clause only if there are friends to exclude
|
||||
const notInClause = friends.length > 0
|
||||
? `AND u.id NOT IN (${friends.map(() => '?').join(',')})`
|
||||
: '';
|
||||
|
||||
const challengeFriends = await query(
|
||||
`SELECT DISTINCT
|
||||
u.id, u.username, u.email,
|
||||
@@ -66,7 +71,7 @@ router.get('/', authMiddleware, asyncHandler(async (req, res) => {
|
||||
INNER JOIN challenges c ON cp.challenge_id = c.id
|
||||
WHERE c.created_by = ? AND cp.user_id != ? AND cp.status = 'accepted'
|
||||
)
|
||||
AND u.id NOT IN (${friends.map(() => '?').join(',') || 'NULL'})
|
||||
${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)]
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user