Skip to content

Commit 21500c7

Browse files
fix: remove _count children query from EventType and Workflow repositories (calcom#27309)
Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
1 parent fd476bf commit 21500c7

5 files changed

Lines changed: 18 additions & 61 deletions

File tree

apps/web/modules/ee/workflows/components/WorkflowListPage.tsx

Lines changed: 11 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
1-
import { useAutoAnimate } from "@formkit/auto-animate/react";
2-
import Link from "next/link";
3-
import { useRouter } from "next/navigation";
4-
import { useState } from "react";
5-
61
import { getActionIcon } from "@calcom/features/ee/workflows/lib/getActionIcon";
72
import type { WorkflowListType } from "@calcom/features/ee/workflows/lib/types";
83
import { getPlaceholderAvatar } from "@calcom/lib/defaultAvatarImage";
@@ -23,7 +18,10 @@ import {
2318
} from "@calcom/ui/components/dropdown";
2419
import { Icon } from "@calcom/ui/components/icon";
2520
import { Tooltip } from "@calcom/ui/components/tooltip";
26-
21+
import { useAutoAnimate } from "@formkit/auto-animate/react";
22+
import Link from "next/link";
23+
import { useRouter } from "next/navigation";
24+
import { useState } from "react";
2725
import { DeleteDialog } from "./DeleteDialog";
2826

2927
/** @deprecated Use WorkflowListType from ../lib/types instead */
@@ -102,12 +100,12 @@ export default function WorkflowListPage({ workflows }: Props) {
102100
{workflow.name
103101
? workflow.name
104102
: workflow.steps[0]
105-
? `Untitled (${`${t(`${workflow.steps[0].action.toLowerCase()}_action`)}`
106-
.charAt(0)
107-
.toUpperCase()}${`${t(
108-
`${workflow.steps[0].action.toLowerCase()}_action`
109-
)}`.slice(1)})`
110-
: "Untitled"}
103+
? `Untitled (${`${t(`${workflow.steps[0].action.toLowerCase()}_action`)}`
104+
.charAt(0)
105+
.toUpperCase()}${`${t(
106+
`${workflow.steps[0].action.toLowerCase()}_action`
107+
)}`.slice(1)})`
108+
: "Untitled"}
111109
</div>
112110
<div>
113111
{(workflow.permissions?.readOnly ?? workflow.readOnly) && (
@@ -147,14 +145,7 @@ export default function WorkflowListPage({ workflows }: Props) {
147145
<Tooltip
148146
content={workflow.activeOn
149147
.filter((wf) => (workflow.teamId ? wf.eventType.parentId === null : true))
150-
.map((activeOn, key) => (
151-
<p key={key}>
152-
{activeOn.eventType.title}
153-
{activeOn.eventType._count.children > 0
154-
? ` (+${activeOn.eventType._count.children})`
155-
: ""}
156-
</p>
157-
))}>
148+
.map((activeOn, key) => <p key={key}>{activeOn.eventType.title}</p>)}>
158149
<div>
159150
<Icon name="link" className="mr-1.5 inline h-3 w-3" aria-hidden="true" />
160151
{t("active_on_event_types", {

packages/features/ee/workflows/lib/types.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,9 +123,6 @@ export type WorkflowListType = PrismaWorkflow & {
123123
id: number;
124124
title: string;
125125
parentId: number | null;
126-
_count: {
127-
children: number;
128-
};
129126
};
130127
}[];
131128
readOnly?: boolean;

packages/features/ee/workflows/repositories/WorkflowRepository.ts

Lines changed: 6 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
1-
import { z } from "zod";
2-
31
import { FORM_TRIGGER_WORKFLOW_EVENTS } from "@calcom/ee/workflows/lib/constants";
42
import { deleteScheduledAIPhoneCall } from "@calcom/ee/workflows/lib/reminders/aiPhoneCallManager";
53
import { deleteScheduledEmailReminder } from "@calcom/ee/workflows/lib/reminders/emailReminderManager";
64
import { deleteScheduledSMSReminder } from "@calcom/ee/workflows/lib/reminders/smsReminderManager";
7-
import type { WorkflowListType as WorkflowType } from "@calcom/ee/workflows/lib/types";
8-
import type { WorkflowStep } from "@calcom/ee/workflows/lib/types";
5+
import type { WorkflowStep, WorkflowListType as WorkflowType } from "@calcom/ee/workflows/lib/types";
96
import { hasFilter } from "@calcom/features/filters/lib/hasFilter";
107
import { PermissionCheckService } from "@calcom/features/pbac/services/permission-check.service";
118
import { HttpError } from "@calcom/lib/http-error";
@@ -14,14 +11,15 @@ import prisma from "@calcom/prisma";
1411
import type { Prisma } from "@calcom/prisma/client";
1512
import {
1613
MembershipRole,
17-
TimeUnit,
18-
WorkflowTriggerEvents,
1914
WorkflowType as PrismaWorkflowType,
15+
type TimeUnit,
16+
WorkflowMethods,
17+
type WorkflowTriggerEvents,
2018
} from "@calcom/prisma/enums";
21-
import { WorkflowMethods } from "@calcom/prisma/enums";
2219
import type { TFilteredListInputSchema } from "@calcom/trpc/server/routers/viewer/workflows/filteredList.schema";
2320
import type { TGetVerifiedEmailsInputSchema } from "@calcom/trpc/server/routers/viewer/workflows/getVerifiedEmails.schema";
2421
import type { TGetVerifiedNumbersInputSchema } from "@calcom/trpc/server/routers/viewer/workflows/getVerifiedNumbers.schema";
22+
import { z } from "zod";
2523

2624
export const ZGetInputSchema = z.object({
2725
id: z.number(),
@@ -54,11 +52,6 @@ const includedFields = {
5452
id: true,
5553
title: true,
5654
parentId: true,
57-
_count: {
58-
select: {
59-
children: true,
60-
},
61-
},
6255
},
6356
},
6457
},
@@ -486,7 +479,7 @@ export class WorkflowRepository {
486479

487480
results.forEach((result, index) => {
488481
if (result.status !== "fulfilled") {
489-
this.log.error(
482+
WorkflowRepository.log.error(
490483
`An error occurred when deleting reminder ${remindersToDelete[index].id}, method: ${remindersToDelete[index].method}`,
491484
result.reason
492485
);
@@ -695,11 +688,6 @@ export class WorkflowRepository {
695688
id: true,
696689
title: true,
697690
parentId: true,
698-
_count: {
699-
select: {
700-
children: true,
701-
},
702-
},
703691
},
704692
},
705693
},
@@ -732,11 +720,6 @@ export class WorkflowRepository {
732720
id: true,
733721
title: true,
734722
parentId: true,
735-
_count: {
736-
select: {
737-
children: true,
738-
},
739-
},
740723
},
741724
},
742725
},
@@ -789,11 +772,6 @@ export class WorkflowRepository {
789772
id: true,
790773
title: true,
791774
parentId: true,
792-
_count: {
793-
select: {
794-
children: true,
795-
},
796-
},
797775
},
798776
},
799777
},

packages/features/eventtypes/repositories/eventTypeRepository.ts

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -789,11 +789,6 @@ export class EventTypeRepository implements IEventTypesRepository {
789789
id: true,
790790
title: true,
791791
parentId: true,
792-
_count: {
793-
select: {
794-
children: true,
795-
},
796-
},
797792
},
798793
},
799794
},
@@ -1100,11 +1095,6 @@ export class EventTypeRepository implements IEventTypesRepository {
11001095
id: true,
11011096
title: true,
11021097
parentId: true,
1103-
_count: {
1104-
select: {
1105-
children: true,
1106-
},
1107-
},
11081098
},
11091099
},
11101100
},

packages/trpc/server/routers/viewer/eventTypes/get.handler.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// Cache bust: workflows.activeOn.eventType no longer includes _count.children
12
import getEventTypeById from "@calcom/features/eventtypes/lib/getEventTypeById";
23
import type { PrismaClient } from "@calcom/prisma";
34

0 commit comments

Comments
 (0)