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 <[email protected]>
This commit is contained in:
Keith WilliamsandAlan authored and GitHub committed 2023-09-05 11:35:02 -07:00
1 parent 3f0380617a
commit b4b90f2d27
4 files changed
+24 -17

No files matched your search

@@ -20,14 +20,9 @@ import {
Tooltip,
Badge,
Avatar,
ArrowButton
ArrowButton,
} from "@calcom/ui";
import {
Edit2,
Link as LinkIcon,
MoreHorizontal,
Trash2,
} from "@calcom/ui/components/icon";
import { Edit2, Link as LinkIcon, MoreHorizontal, Trash2 } from "@calcom/ui/components/icon";
import { useOrgBranding } from "../../organizations/context/provider";
import { subdomainSuffix } from "../../organizations/lib/orgDomains";
@@ -32,11 +32,10 @@ const userSelect = Prisma.validator<Prisma.UserSelect>()({
name: true,
});
const eventTypeSelect = Prisma.validator<Prisma.EventTypeSelect>()({
const userEventTypeSelect = 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,
hashedLink: true,
locations: true,
destinationCalendar: true,
userId: true,
team: {
@@ -53,6 +52,7 @@ const eventTypeSelect = Prisma.validator<Prisma.EventTypeSelect>()({
users: {
select: userSelect,
},
// Temporarily putting this back for testing
children: {
include: {
users: {
@@ -72,6 +72,17 @@ const eventTypeSelect = Prisma.validator<Prisma.EventTypeSelect>()({
...baseEventTypeSelect,
});
const teamEventTypeSelect = Prisma.validator<Prisma.EventTypeSelect>()({
...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",