perf: fetch only by id (#19154)
* perf: fetch only by id * remove getServerSession --------- Co-authored-by: hbjORbj <[email protected]>
This commit is contained in:
1 parent
0fb0974769
commit
76c09ca7bf
2 files changed
+5
-35
No files matched your search
@@ -4,10 +4,9 @@ import { _generateMetadata } from "app/_utils";
|
|||||||
import { cookies, headers } from "next/headers";
|
import { cookies, headers } from "next/headers";
|
||||||
import { z } from "zod";
|
import { z } from "zod";
|
||||||
|
|
||||||
import { getServerSession } from "@calcom/features/auth/lib/getServerSession";
|
|
||||||
import { EventTypeRepository } from "@calcom/lib/server/repository/eventType";
|
import { EventTypeRepository } from "@calcom/lib/server/repository/eventType";
|
||||||
|
|
||||||
import { buildLegacyCtx, buildLegacyRequest } from "@lib/buildLegacyCtx";
|
import { buildLegacyCtx } from "@lib/buildLegacyCtx";
|
||||||
import type { PageProps as EventTypePageProps } from "@lib/event-types/[type]/getServerSideProps";
|
import type { PageProps as EventTypePageProps } from "@lib/event-types/[type]/getServerSideProps";
|
||||||
import { getServerSideProps } from "@lib/event-types/[type]/getServerSideProps";
|
import { getServerSideProps } from "@lib/event-types/[type]/getServerSideProps";
|
||||||
|
|
||||||
@@ -23,9 +22,8 @@ const querySchema = z.object({
|
|||||||
});
|
});
|
||||||
|
|
||||||
export const generateMetadata = async ({ params }: _PageProps) => {
|
export const generateMetadata = async ({ params }: _PageProps) => {
|
||||||
const session = await getServerSession({ req: buildLegacyRequest(headers(), cookies()) });
|
|
||||||
const parsed = querySchema.safeParse(params);
|
const parsed = querySchema.safeParse(params);
|
||||||
if (!parsed.success || !session?.user?.id) {
|
if (!parsed.success) {
|
||||||
return await _generateMetadata(
|
return await _generateMetadata(
|
||||||
(t) => `${t("event_type")}`,
|
(t) => `${t("event_type")}`,
|
||||||
() => ""
|
() => ""
|
||||||
@@ -34,7 +32,6 @@ export const generateMetadata = async ({ params }: _PageProps) => {
|
|||||||
|
|
||||||
const data = await EventTypeRepository.findTitleById({
|
const data = await EventTypeRepository.findTitleById({
|
||||||
id: parsed.data.type,
|
id: parsed.data.type,
|
||||||
userId: session?.user?.id,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
return await _generateMetadata(
|
return await _generateMetadata(
|
||||||
|
|||||||
@@ -441,37 +441,10 @@ export class EventTypeRepository {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
static async findTitleById({ id, userId }: { id: number; userId: number }) {
|
static async findTitleById({ id }: { id: number }) {
|
||||||
return await prisma.eventType.findFirst({
|
return await prisma.eventType.findUnique({
|
||||||
where: {
|
where: {
|
||||||
AND: [
|
id,
|
||||||
{
|
|
||||||
OR: [
|
|
||||||
{
|
|
||||||
users: {
|
|
||||||
some: {
|
|
||||||
id: userId,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
team: {
|
|
||||||
members: {
|
|
||||||
some: {
|
|
||||||
userId: userId,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
userId: userId,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id,
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
},
|
||||||
select: {
|
select: {
|
||||||
title: true,
|
title: true,
|
||||||
|
|||||||
Reference in new issue
Block a user