revert: "fix: eventType filter on /insights (#20823)" (#21059)

This reverts commit 45904c07bc.
This commit is contained in:
Eunjae Lee
2025-05-01 15:51:49 +00:00
committed by GitHub
parent 5a35540522
commit 99dc5837f5
@@ -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 filter
if (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,
},
],
};