From 456ae44d43677e03ef838f1c39f06bb99646078c Mon Sep 17 00:00:00 2001 From: Ian Paschal Date: Fri, 8 May 2026 22:37:26 +0200 Subject: [PATCH 1/2] CC-47: TOs Cannot See Player Real Names Fixes CC-42 --- .../_helpers/checkUserTournamentRelationship.ts | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/convex/_model/users/_helpers/checkUserTournamentRelationship.ts b/convex/_model/users/_helpers/checkUserTournamentRelationship.ts index 041ba88d..90c8fe0e 100644 --- a/convex/_model/users/_helpers/checkUserTournamentRelationship.ts +++ b/convex/_model/users/_helpers/checkUserTournamentRelationship.ts @@ -13,16 +13,23 @@ export const checkUserTournamentRelationship = async ( const userARegistrations = await ctx.db.query('tournamentRegistrations') .withIndex('by_user', (q) => q.eq('userId', userIdA)) .collect(); - const userBRegistrations = await ctx.db.query('tournamentRegistrations') - .withIndex('by_user', (q) => q.eq('userId', userIdB)) + const userAOrganizers = await ctx.db.query('tournamentOrganizers') + .withIndex('by_user', (q) => q.eq('userId', userIdA)) .collect(); - const userATournamentIds = [ ...userARegistrations.map((r) => r.tournamentId), + ...userAOrganizers.map((o) => o.tournamentId), ]; + const userBRegistrations = await ctx.db.query('tournamentRegistrations') + .withIndex('by_user', (q) => q.eq('userId', userIdB)) + .collect(); + const userBOrganizers = await ctx.db.query('tournamentOrganizers') + .withIndex('by_user', (q) => q.eq('userId', userIdB)) + .collect(); const userBTournamentIds = [ ...userBRegistrations.map((r) => r.tournamentId), + ...userBOrganizers.map((o) => o.tournamentId), ]; return userATournamentIds.some((id) => new Set(userBTournamentIds).has(id)); From 18d5c3bbf5a56c9e2cfad7e62b0703ec9c429b1c Mon Sep 17 00:00:00 2001 From: Ian Paschal Date: Fri, 8 May 2026 22:49:10 +0200 Subject: [PATCH 2/2] PR Feedback --- .../checkUserTournamentRelationship.ts | 38 +++++++++++-------- 1 file changed, 23 insertions(+), 15 deletions(-) diff --git a/convex/_model/users/_helpers/checkUserTournamentRelationship.ts b/convex/_model/users/_helpers/checkUserTournamentRelationship.ts index 90c8fe0e..6484cc21 100644 --- a/convex/_model/users/_helpers/checkUserTournamentRelationship.ts +++ b/convex/_model/users/_helpers/checkUserTournamentRelationship.ts @@ -10,27 +10,35 @@ export const checkUserTournamentRelationship = async ( return false; } - const userARegistrations = await ctx.db.query('tournamentRegistrations') - .withIndex('by_user', (q) => q.eq('userId', userIdA)) - .collect(); - const userAOrganizers = await ctx.db.query('tournamentOrganizers') - .withIndex('by_user', (q) => q.eq('userId', userIdA)) - .collect(); + const [ + userARegistrations, + userAOrganizers, + userBRegistrations, + userBOrganizers, + ] = await Promise.all([ + ctx.db.query('tournamentRegistrations') + .withIndex('by_user', (q) => q.eq('userId', userIdA)) + .collect(), + ctx.db.query('tournamentOrganizers') + .withIndex('by_user', (q) => q.eq('userId', userIdA)) + .collect(), + ctx.db.query('tournamentRegistrations') + .withIndex('by_user', (q) => q.eq('userId', userIdB)) + .collect(), + ctx.db.query('tournamentOrganizers') + .withIndex('by_user', (q) => q.eq('userId', userIdB)) + .collect(), + ]); + const userATournamentIds = [ ...userARegistrations.map((r) => r.tournamentId), ...userAOrganizers.map((o) => o.tournamentId), ]; - const userBRegistrations = await ctx.db.query('tournamentRegistrations') - .withIndex('by_user', (q) => q.eq('userId', userIdB)) - .collect(); - const userBOrganizers = await ctx.db.query('tournamentOrganizers') - .withIndex('by_user', (q) => q.eq('userId', userIdB)) - .collect(); - const userBTournamentIds = [ + const userBTournamentIds = new Set>([ ...userBRegistrations.map((r) => r.tournamentId), ...userBOrganizers.map((o) => o.tournamentId), - ]; + ]); - return userATournamentIds.some((id) => new Set(userBTournamentIds).has(id)); + return userATournamentIds.some((id) => userBTournamentIds.has(id)); };