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 <alannnc@gmail.com>
This commit is contained in:
Keith Williams 2023-09-05 15:35:02 -03:00 committed by GitHub
parent 3f0380617a
commit b4b90f2d27
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 24 additions and 17 deletions

View File

@ -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);

View File

@ -402,7 +402,7 @@ export const EventTypeList = ({ group, groupIndex, readOnly, types }: EventTypeL
)}
/>
)}
{isManagedEventType && (
{isManagedEventType && type.children && (
<AvatarGroup
className="relative right-3 top-1"
size="sm"

View File

@ -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";

View File

@ -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",