From be9b0fb9a8029ce4f78dc28ca6fdac9749e54433 Mon Sep 17 00:00:00 2001 From: Keith Williams Date: Tue, 10 Sep 2024 16:40:19 -0300 Subject: [PATCH] perf: Insights - put teamId filter first (#16581) --- .../features/insights/server/trpc-router.ts | 36 +++++++++---------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/packages/features/insights/server/trpc-router.ts b/packages/features/insights/server/trpc-router.ts index 11a95a6cdb..e2953eae0d 100644 --- a/packages/features/insights/server/trpc-router.ts +++ b/packages/features/insights/server/trpc-router.ts @@ -209,18 +209,18 @@ export const insightsRouter = router({ whereConditional = { ...whereConditional, OR: [ - { - userId: { - in: userIdsFromOrg, - }, - isTeamBooking: false, - }, { teamId: { in: [ctx.user.organizationId, ...teamsFromOrg.map((t) => t.id)], }, isTeamBooking: true, }, + { + userId: { + in: userIdsFromOrg, + }, + isTeamBooking: false, + }, ], }; } @@ -436,18 +436,18 @@ export const insightsRouter = router({ whereConditional = { OR: [ - { - userId: { - in: userIdsFromOrg, - }, - isTeamBooking: false, - }, { teamId: { in: [ctx.user.organizationId, ...teamsFromOrg.map((t) => t.id)], }, isTeamBooking: true, }, + { + userId: { + in: userIdsFromOrg, + }, + isTeamBooking: false, + }, ], }; } @@ -614,18 +614,18 @@ export const insightsRouter = router({ bookingWhere = { ...bookingWhere, OR: [ - { - userId: { - in: userIdsFromOrg, - }, - isTeamBooking: false, - }, { teamId: { in: [ctx.user.organizationId, ...teamsFromOrg.map((t) => t.id)], }, isTeamBooking: true, }, + { + userId: { + in: userIdsFromOrg, + }, + isTeamBooking: false, + }, ], }; }