perf: Remove useless data on EvenTypes getByViewer endpoint (#9704)

pull/9712/head
Efraín Rochín 2023-06-22 01:16:53 -07:00 committed by GitHub
parent 79f34a4fc7
commit e5fb19163e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 4 deletions

View File

@ -4,7 +4,7 @@ import { orderBy } from "lodash";
import { hasFilter } from "@calcom/features/filters/lib/hasFilter";
import { CAL_URL } from "@calcom/lib/constants";
import { markdownToSafeHTML } from "@calcom/lib/markdownToSafeHTML";
import { baseEventTypeSelect, baseUserSelect } from "@calcom/prisma";
import { baseEventTypeSelect } from "@calcom/prisma";
import { MembershipRole, SchedulingType } from "@calcom/prisma/enums";
import { teamMetadataSchema } from "@calcom/prisma/zod-utils";
import { EventTypeMetaDataSchema } from "@calcom/prisma/zod-utils";
@ -22,6 +22,12 @@ type GetByViewerOptions = {
input: TEventTypeInputSchema;
};
const userSelect = Prisma.validator<Prisma.UserSelect>()({
id: true,
username: true,
name: true,
});
const eventTypeSelect = Prisma.validator<Prisma.EventTypeSelect>()({
// 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,
@ -41,12 +47,12 @@ const eventTypeSelect = Prisma.validator<Prisma.EventTypeSelect>()({
},
metadata: true,
users: {
select: baseUserSelect,
select: userSelect,
},
children: {
include: {
users: {
select: baseUserSelect,
select: userSelect,
},
},
},
@ -54,7 +60,7 @@ const eventTypeSelect = Prisma.validator<Prisma.EventTypeSelect>()({
hosts: {
select: {
user: {
select: baseUserSelect,
select: userSelect,
},
},
},