-
Notifications
You must be signed in to change notification settings - Fork 8.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
perf: don't fetch all the hosts [DO NOT MERGE] #18319
Open
Udit-takkar
wants to merge
15
commits into
main
Choose a base branch
from
perf/event-query
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
1b75918
perf: don't fetch all the hosts
Udit-takkar de03a0f
fix: type err
Udit-takkar f1162dd
Merge branch 'main' into perf/event-query
alishaz-polymath 9eaa3f6
use appschema only when necessary
hariombalhara 0572464
Merge remote-tracking branch 'origin/fix-ts-crash-api-v2' into perf/e…
hariombalhara cd127e8
Variable casing change and type fixes
hariombalhara 04aca73
Merge remote-tracking branch 'origin/fix-ts-crash-api-v2' into perf/e…
hariombalhara 564cec0
Another fix
hariombalhara 41299b8
Merge remote-tracking branch 'origin/fix-ts-crash-api-v2' into perf/e…
hariombalhara 4819bad
Another missing ts fix
hariombalhara 6269de7
Merge remote-tracking branch 'origin/fix-ts-crash-api-v2' into perf/e…
hariombalhara ead0cec
chore: update variable name
Udit-takkar 040dfd4
Merge branch 'main' into perf/event-query
anikdhabal 39e64ff
check for undefined metadata
227da92
Merge branch 'main' into perf/event-query
Udit-takkar File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -50,99 +50,6 @@ const userSelect = Prisma.validator<Prisma.UserSelect>()({ | |
defaultScheduleId: true, | ||
}); | ||
|
||
const publicEventSelect = Prisma.validator<Prisma.EventTypeSelect>()({ | ||
id: true, | ||
title: true, | ||
description: true, | ||
eventName: true, | ||
slug: true, | ||
isInstantEvent: true, | ||
instantMeetingParameters: true, | ||
aiPhoneCallConfig: true, | ||
schedulingType: true, | ||
length: true, | ||
locations: true, | ||
customInputs: true, | ||
disableGuests: true, | ||
metadata: true, | ||
lockTimeZoneToggleOnBookingPage: true, | ||
requiresConfirmation: true, | ||
autoTranslateDescriptionEnabled: true, | ||
fieldTranslations: { | ||
select: { | ||
translatedText: true, | ||
targetLocale: true, | ||
field: true, | ||
}, | ||
}, | ||
requiresBookerEmailVerification: true, | ||
recurringEvent: true, | ||
price: true, | ||
currency: true, | ||
seatsPerTimeSlot: true, | ||
seatsShowAvailabilityCount: true, | ||
bookingFields: true, | ||
teamId: true, | ||
team: { | ||
select: { | ||
parentId: true, | ||
metadata: true, | ||
brandColor: true, | ||
darkBrandColor: true, | ||
slug: true, | ||
name: true, | ||
logoUrl: true, | ||
theme: true, | ||
parent: { | ||
select: { | ||
slug: true, | ||
name: true, | ||
bannerUrl: true, | ||
logoUrl: true, | ||
}, | ||
}, | ||
isPrivate: true, | ||
}, | ||
}, | ||
successRedirectUrl: true, | ||
forwardParamsSuccessRedirect: true, | ||
workflows: { | ||
include: { | ||
workflow: { | ||
include: { | ||
steps: true, | ||
}, | ||
}, | ||
}, | ||
}, | ||
hosts: { | ||
select: { | ||
user: { | ||
select: userSelect, | ||
}, | ||
}, | ||
}, | ||
owner: { | ||
select: userSelect, | ||
}, | ||
schedule: { | ||
select: { | ||
id: true, | ||
timeZone: true, | ||
}, | ||
}, | ||
instantMeetingSchedule: { | ||
select: { | ||
id: true, | ||
timeZone: true, | ||
}, | ||
}, | ||
|
||
hidden: true, | ||
assignAllTeamMembers: true, | ||
rescheduleWithSameRoundRobinHost: true, | ||
}); | ||
|
||
export async function isCurrentlyAvailable({ | ||
prisma, | ||
instantMeetingScheduleId, | ||
|
@@ -209,6 +116,102 @@ function isAvailableInTimeSlot( | |
return isWithinPeriod; | ||
} | ||
|
||
const getPublicEventSelect = (limitHostsToThree?: boolean) => { | ||
return Prisma.validator<Prisma.EventTypeSelect>()({ | ||
id: true, | ||
title: true, | ||
description: true, | ||
eventName: true, | ||
slug: true, | ||
isInstantEvent: true, | ||
instantMeetingParameters: true, | ||
aiPhoneCallConfig: true, | ||
schedulingType: true, | ||
length: true, | ||
locations: true, | ||
customInputs: true, | ||
disableGuests: true, | ||
metadata: true, | ||
lockTimeZoneToggleOnBookingPage: true, | ||
requiresConfirmation: true, | ||
autoTranslateDescriptionEnabled: true, | ||
fieldTranslations: { | ||
select: { | ||
translatedText: true, | ||
targetLocale: true, | ||
field: true, | ||
}, | ||
}, | ||
requiresBookerEmailVerification: true, | ||
recurringEvent: true, | ||
price: true, | ||
currency: true, | ||
seatsPerTimeSlot: true, | ||
seatsShowAvailabilityCount: true, | ||
bookingFields: true, | ||
teamId: true, | ||
team: { | ||
select: { | ||
parentId: true, | ||
metadata: true, | ||
brandColor: true, | ||
darkBrandColor: true, | ||
slug: true, | ||
name: true, | ||
logoUrl: true, | ||
theme: true, | ||
parent: { | ||
select: { | ||
slug: true, | ||
name: true, | ||
bannerUrl: true, | ||
logoUrl: true, | ||
}, | ||
}, | ||
isPrivate: true, | ||
}, | ||
}, | ||
successRedirectUrl: true, | ||
forwardParamsSuccessRedirect: true, | ||
workflows: { | ||
include: { | ||
workflow: { | ||
include: { | ||
steps: true, | ||
}, | ||
}, | ||
}, | ||
}, | ||
hosts: { | ||
select: { | ||
user: { | ||
select: userSelect, | ||
}, | ||
}, | ||
...(limitHostsToThree ? { take: 3 } : {}), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We would still need all the hosts for single event type page so we don't want the limit everytime |
||
}, | ||
owner: { | ||
select: userSelect, | ||
}, | ||
schedule: { | ||
select: { | ||
id: true, | ||
timeZone: true, | ||
}, | ||
}, | ||
instantMeetingSchedule: { | ||
select: { | ||
id: true, | ||
timeZone: true, | ||
}, | ||
}, | ||
|
||
hidden: true, | ||
assignAllTeamMembers: true, | ||
rescheduleWithSameRoundRobinHost: true, | ||
}); | ||
}; | ||
|
||
// TODO: Convert it to accept a single parameter with structured data | ||
export const getPublicEvent = async ( | ||
username: string, | ||
|
@@ -217,8 +220,10 @@ export const getPublicEvent = async ( | |
org: string | null, | ||
prisma: PrismaClient, | ||
fromRedirectOfNonOrgLink: boolean, | ||
currentUserId?: number | ||
currentUserId?: number, | ||
limitHostsToThree?: boolean | ||
) => { | ||
const publicEventSelect = getPublicEventSelect(limitHostsToThree); | ||
const usernameList = getUsernameList(username); | ||
const orgQuery = org ? getSlugOrRequestedSlug(org) : null; | ||
// In case of dynamic group event, we fetch user's data and use the default event. | ||
|
@@ -504,7 +509,7 @@ export const getPublicEvent = async ( | |
}; | ||
|
||
const eventData = Prisma.validator<Prisma.EventTypeArgs>()({ | ||
select: publicEventSelect, | ||
select: getPublicEventSelect(false), | ||
}); | ||
|
||
type Event = Prisma.EventTypeGetPayload<typeof eventData>; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we don't need all the hosts on the front end