From b4b90f2d2717328aaa87388b3dc4938c845dcb72 Mon Sep 17 00:00:00 2001 From: Keith Williams Date: Tue, 5 Sep 2023 15:35:02 -0300 Subject: [PATCH] perf: Removed unused queries for user event types (#10568) * perf: Removed unused queries for user event types * Added empty children array * Refactor to clean up * Fixing type issue * Removed extra call to get raw event types * Temporarily putting children back * Removing include from children * Added check for children * Put children back for testing --------- Co-authored-by: Alan --- apps/ai/next.config.js | 7 +++--- apps/web/pages/event-types/index.tsx | 2 +- .../workflows/components/WorkflowListPage.tsx | 9 ++------ .../viewer/eventTypes/getByViewer.handler.ts | 23 +++++++++++++++---- 4 files changed, 24 insertions(+), 17 deletions(-) diff --git a/apps/ai/next.config.js b/apps/ai/next.config.js index bdeffec2dc..747ded2324 100644 --- a/apps/ai/next.config.js +++ b/apps/ai/next.config.js @@ -8,11 +8,11 @@ const nextConfig = { async redirects() { return [ { - source: '/', - destination: 'https://cal.com/ai', + source: "/", + destination: "https://cal.com/ai", permanent: true, }, - ] + ]; }, i18n: { defaultLocale: "en", @@ -22,4 +22,3 @@ const nextConfig = { }; module.exports = () => plugins.reduce((acc, next) => next(acc), nextConfig); - diff --git a/apps/web/pages/event-types/index.tsx b/apps/web/pages/event-types/index.tsx index 0e30f528e9..4bb0978e59 100644 --- a/apps/web/pages/event-types/index.tsx +++ b/apps/web/pages/event-types/index.tsx @@ -402,7 +402,7 @@ export const EventTypeList = ({ group, groupIndex, readOnly, types }: EventTypeL )} /> )} - {isManagedEventType && ( + {isManagedEventType && type.children && ( ()({ name: true, }); -const eventTypeSelect = Prisma.validator()({ +const userEventTypeSelect = Prisma.validator()({ // Position is required by lodash to sort on it. Don't remove it, TS won't complain but it would silently break reordering position: true, hashedLink: true, - locations: true, destinationCalendar: true, userId: true, team: { @@ -53,6 +52,7 @@ const eventTypeSelect = Prisma.validator()({ users: { select: userSelect, }, + // Temporarily putting this back for testing children: { include: { users: { @@ -72,6 +72,17 @@ const eventTypeSelect = Prisma.validator()({ ...baseEventTypeSelect, }); +const teamEventTypeSelect = Prisma.validator()({ + ...userEventTypeSelect, + // children: { + // include: { + // users: { + // select: userSelect, + // }, + // }, + // }, +}); + export const compareMembership = (mship1: MembershipRole, mship2: MembershipRole) => { const mshipToNumber = (mship: MembershipRole) => Object.keys(MembershipRole).findIndex((mmship) => mmship === mship); @@ -118,7 +129,7 @@ export const getByViewerHandler = async ({ ctx, input }: GetByViewerOptions) => }, }, eventTypes: { - select: eventTypeSelect, + select: teamEventTypeSelect, orderBy: [ { position: "desc", @@ -134,10 +145,12 @@ export const getByViewerHandler = async ({ ctx, input }: GetByViewerOptions) => }, eventTypes: { where: { - team: null, + teamId: null, userId: getPrismaWhereUserIdFromFilter(ctx.user.id, input?.filters), }, - select: eventTypeSelect, + select: { + ...userEventTypeSelect, + }, orderBy: [ { position: "desc",