-
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: /router endpoint perf improvement #18366
base: main
Are you sure you want to change the base?
Conversation
acba639
to
9379810
Compare
Hey there and thank you for opening this pull request! 👋🏼 We require pull request titles to follow the Conventional Commits specification and it looks like your proposed title needs to be adjusted. Details:
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎ 2 Skipped Deployments
|
@@ -178,6 +186,9 @@ export const getServerSideProps = async function getServerSideProps( | |||
serializableForm.fields | |||
); | |||
|
|||
// TODO: To be done using sentry tracing | |||
console.log("Server-Timing", getServerTimingHeader(timeTaken)); |
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.
timeTaken
is already being computed, so I will just use the same approach for now for quick release. I will later move it to Sentry.
const { createContext } = await import("@calcom/trpc/server/createContext"); | ||
const ctx = await createContext(context); | ||
|
||
const { default: trpcRouter } = await import("@calcom/app-store/routing-forms/trpc/_router"); | ||
const caller = trpcRouter.createCaller(ctx); |
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.
Avoid using another trpcHandler
and instead use the utility directly.
Also, needed to do this so that I can easily pass on already queried form
to handleResponse
and avoid repeat querying of same data
9379810
to
86bb2ba
Compare
include: { | ||
team: { | ||
select: { | ||
parentId: true, |
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.
New requirement, it was already queried in /router endpoint for some other requirement
86bb2ba
to
1d9d8cb
Compare
|
||
const form = await prisma.app_RoutingForms_Form.findFirst({ | ||
async function findFormById(formId: string, prisma: AppPrisma) { | ||
return await prisma.app_RoutingForms_Form.findUnique({ |
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.
Using findUnique
instead of findFirst
1d9d8cb
to
6f56f8e
Compare
6f56f8e
to
3dff0ca
Compare
E2E results are ready! |
What does this PR do?
findUnique
for form query instead offindFirst
handleResponse
from response.handler.ts to be reused in /router - It allows already available form to be passed directly tohandleResponse
and avoids one sequential query to DB.orgId
directly tofindTeamMembersMatchingAttributeLogic
which helps in restricting the number of records being queried in attributes related tables.getAttributesAssignmentData
avoidingsome
queries in Prisma and using some in memory calculations.Improvement seen locally:
Mandatory Tasks (DO NOT REMOVE)
How should this be tested?
Followup
teamMembershipId
column inattributeToUser
could possibly save some querying time, if in-memory computation for orgMembershipId to userId doesn't work