Scheduling infrastructure for absolutely everyone.
revert: "fix: eventType filter on /insights (#20823)" (#21059)
Eunjae Lee99dc5837f50e
diff --git a/packages/features/insights/server/trpc-router.ts b/packages/features/insights/server/trpc-router.tsindex 8bb69a46649..58a687fcb21 100644--- a/packages/features/insights/server/trpc-router.ts+++ b/packages/features/insights/server/trpc-router.ts@@ -53,9 +53,8 @@ const buildBaseWhereCondition = async ({isEmptyResponse?: boolean;}> => {let whereCondition: Prisma.BookingTimeStatusWhereInput = {};- const ANDConditions: Prisma.BookingTimeStatusWhereInput[] = [];// EventType Filter- if (eventTypeId) ANDConditions.push({ OR: [{ eventTypeId }, { eventParentId: eventTypeId }] });+ if (eventTypeId) whereCondition.OR = [{ eventTypeId }, { eventParentId: eventTypeId }];// User/Member filterif (memberUserId) whereCondition.userId = memberUserId;if (userId) {@@ -77,9 +76,13 @@ const buildBaseWhereCondition = async ({return {whereCondition: {...whereCondition,- teamId: ctx.userOrganizationId,- isTeamBooking: true,- ...(ANDConditions.length > 0 ? { AND: [...ANDConditions] } : {}),+ OR: [+ ...(whereCondition.OR ?? []),+ {+ teamId: ctx.userOrganizationId,+ isTeamBooking: true,+ },+ ],},isEmptyResponse: true,};@@ -102,23 +105,18 @@ const buildBaseWhereCondition = async ({const userIdsFromOrg = usersFromOrg.map((u) => u.userId);whereCondition = {...whereCondition,- AND: [- ...ANDConditions,+ OR: [{- OR: [- {- teamId: {- in: [ctx.userOrganizationId, ...teamsFromOrg.map((t) => t.id)],- },- isTeamBooking: true,- },- {- userId: {- in: userIdsFromOrg,- },- isTeamBooking: false,- },- ],+ teamId: {+ in: [ctx.userOrganizationId, ...teamsFromOrg.map((t) => t.id)],+ },+ isTeamBooking: true,+ },+ {+ userId: {+ in: userIdsFromOrg,+ },+ isTeamBooking: false,},],};@@ -137,21 +135,16 @@ const buildBaseWhereCondition = async ({const userIdsFromTeam = usersFromTeam.map((u) => u.userId);whereCondition = {...whereCondition,- AND: [- ...ANDConditions,+ OR: [{- OR: [- {- teamId,- isTeamBooking: true,- },- {- userId: {- in: userIdsFromTeam,- },- isTeamBooking: false,- },- ],+ teamId,+ isTeamBooking: true,+ },+ {+ userId: {+ in: userIdsFromTeam,+ },+ isTeamBooking: false,},],};