fix: remove _count children query from EventType and Workflow repositories (#27309)

Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
Keith WilliamsandDevin AI authored and GitHub committed 2026-01-27 15:23:26 -03:00
1 parent fd476bf7f7
commit 21500c7047
5 files changed
+18 -61

No files matched your search

@@ -1,8 +1,3 @@
import { useAutoAnimate } from "@formkit/auto-animate/react";
import Link from "next/link";
import { useRouter } from "next/navigation";
import { useState } from "react";
import { getActionIcon } from "@calcom/features/ee/workflows/lib/getActionIcon";
import type { WorkflowListType } from "@calcom/features/ee/workflows/lib/types";
import { getPlaceholderAvatar } from "@calcom/lib/defaultAvatarImage";
@@ -23,7 +18,10 @@ import {
} from "@calcom/ui/components/dropdown";
import { Icon } from "@calcom/ui/components/icon";
import { Tooltip } from "@calcom/ui/components/tooltip";
import { useAutoAnimate } from "@formkit/auto-animate/react";
import Link from "next/link";
import { useRouter } from "next/navigation";
import { useState } from "react";
import { DeleteDialog } from "./DeleteDialog";
/** @deprecated Use WorkflowListType from ../lib/types instead */
@@ -102,12 +100,12 @@ export default function WorkflowListPage({ workflows }: Props) {
{workflow.name
? workflow.name
: workflow.steps[0]
? `Untitled (${`${t(`${workflow.steps[0].action.toLowerCase()}_action`)}`
.charAt(0)
.toUpperCase()}${`${t(
`${workflow.steps[0].action.toLowerCase()}_action`
)}`.slice(1)})`
: "Untitled"}
? `Untitled (${`${t(`${workflow.steps[0].action.toLowerCase()}_action`)}`
.charAt(0)
.toUpperCase()}${`${t(
`${workflow.steps[0].action.toLowerCase()}_action`
)}`.slice(1)})`
: "Untitled"}
</div>
<div>
{(workflow.permissions?.readOnly ?? workflow.readOnly) && (
@@ -147,14 +145,7 @@ export default function WorkflowListPage({ workflows }: Props) {
<Tooltip
content={workflow.activeOn
.filter((wf) => (workflow.teamId ? wf.eventType.parentId === null : true))
.map((activeOn, key) => (
<p key={key}>
{activeOn.eventType.title}
{activeOn.eventType._count.children > 0
? ` (+${activeOn.eventType._count.children})`
: ""}
</p>
))}>
.map((activeOn, key) => <p key={key}>{activeOn.eventType.title}</p>)}>
<div>
<Icon name="link" className="mr-1.5 inline h-3 w-3" aria-hidden="true" />
{t("active_on_event_types", {
@@ -123,9 +123,6 @@ export type WorkflowListType = PrismaWorkflow & {
id: number;
title: string;
parentId: number | null;
_count: {
children: number;
};
};
}[];
readOnly?: boolean;
@@ -1,11 +1,8 @@
import { z } from "zod";
import { FORM_TRIGGER_WORKFLOW_EVENTS } from "@calcom/ee/workflows/lib/constants";
import { deleteScheduledAIPhoneCall } from "@calcom/ee/workflows/lib/reminders/aiPhoneCallManager";
import { deleteScheduledEmailReminder } from "@calcom/ee/workflows/lib/reminders/emailReminderManager";
import { deleteScheduledSMSReminder } from "@calcom/ee/workflows/lib/reminders/smsReminderManager";
import type { WorkflowListType as WorkflowType } from "@calcom/ee/workflows/lib/types";
import type { WorkflowStep } from "@calcom/ee/workflows/lib/types";
import type { WorkflowStep, WorkflowListType as WorkflowType } from "@calcom/ee/workflows/lib/types";
import { hasFilter } from "@calcom/features/filters/lib/hasFilter";
import { PermissionCheckService } from "@calcom/features/pbac/services/permission-check.service";
import { HttpError } from "@calcom/lib/http-error";
@@ -14,14 +11,15 @@ import prisma from "@calcom/prisma";
import type { Prisma } from "@calcom/prisma/client";
import {
MembershipRole,
TimeUnit,
WorkflowTriggerEvents,
WorkflowType as PrismaWorkflowType,
type TimeUnit,
WorkflowMethods,
type WorkflowTriggerEvents,
} from "@calcom/prisma/enums";
import { WorkflowMethods } from "@calcom/prisma/enums";
import type { TFilteredListInputSchema } from "@calcom/trpc/server/routers/viewer/workflows/filteredList.schema";
import type { TGetVerifiedEmailsInputSchema } from "@calcom/trpc/server/routers/viewer/workflows/getVerifiedEmails.schema";
import type { TGetVerifiedNumbersInputSchema } from "@calcom/trpc/server/routers/viewer/workflows/getVerifiedNumbers.schema";
import { z } from "zod";
export const ZGetInputSchema = z.object({
id: z.number(),
@@ -54,11 +52,6 @@ const includedFields = {
id: true,
title: true,
parentId: true,
_count: {
select: {
children: true,
},
},
},
},
},
@@ -486,7 +479,7 @@ export class WorkflowRepository {
results.forEach((result, index) => {
if (result.status !== "fulfilled") {
this.log.error(
WorkflowRepository.log.error(
`An error occurred when deleting reminder ${remindersToDelete[index].id}, method: ${remindersToDelete[index].method}`,
result.reason
);
@@ -695,11 +688,6 @@ export class WorkflowRepository {
id: true,
title: true,
parentId: true,
_count: {
select: {
children: true,
},
},
},
},
},
@@ -732,11 +720,6 @@ export class WorkflowRepository {
id: true,
title: true,
parentId: true,
_count: {
select: {
children: true,
},
},
},
},
},
@@ -789,11 +772,6 @@ export class WorkflowRepository {
id: true,
title: true,
parentId: true,
_count: {
select: {
children: true,
},
},
},
},
},
@@ -789,11 +789,6 @@ export class EventTypeRepository implements IEventTypesRepository {
id: true,
title: true,
parentId: true,
_count: {
select: {
children: true,
},
},
},
},
},
@@ -1100,11 +1095,6 @@ export class EventTypeRepository implements IEventTypesRepository {
id: true,
title: true,
parentId: true,
_count: {
select: {
children: true,
},
},
},
},
},
@@ -1,3 +1,4 @@
// Cache bust: workflows.activeOn.eventType no longer includes _count.children
import getEventTypeById from "@calcom/features/eventtypes/lib/getEventTypeById";
import type { PrismaClient } from "@calcom/prisma";