perf: leverage DB index for user profile fetching (booking page & payment page) (#21814)

* leverage DB index for findByUserIdAndOrgSlug method

* booking view

* payment view

* fix

* fix

* address comment
This commit is contained in:
Benny Joo authored and GitHub committed 2025-06-18 09:53:12 +03:00
1 parent 7900be3a30
commit e27de47d9f
4 files changed
+22 -13

No files matched your search

+14 -3
View File
@@ -665,9 +665,20 @@ export class ProfileRepository {
return normalizeProfile(profile);
}
static async findByUserIdAndOrgSlug({ userId, orgSlug }: { userId: number; orgSlug: string }) {
const profile = await prisma.profile.findFirst({
where: { userId, organization: { slug: orgSlug } },
static async findByUserIdAndOrgSlug({
userId,
organizationId,
}: {
userId: number;
organizationId: number;
}) {
const profile = await prisma.profile.findUnique({
where: {
userId_organizationId: {
userId,
organizationId,
},
},
include: {
organization: {
select: organizationSelect,