perf: fetch only by id (#19154)
* perf: fetch only by id * remove getServerSession --------- Co-authored-by: hbjORbj <sldisek783@gmail.com>
This commit is contained in:
@@ -4,10 +4,9 @@ import { _generateMetadata } from "app/_utils";
|
||||
import { cookies, headers } from "next/headers";
|
||||
import { z } from "zod";
|
||||
|
||||
import { getServerSession } from "@calcom/features/auth/lib/getServerSession";
|
||||
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 { getServerSideProps } from "@lib/event-types/[type]/getServerSideProps";
|
||||
|
||||
@@ -23,9 +22,8 @@ const querySchema = z.object({
|
||||
});
|
||||
|
||||
export const generateMetadata = async ({ params }: _PageProps) => {
|
||||
const session = await getServerSession({ req: buildLegacyRequest(headers(), cookies()) });
|
||||
const parsed = querySchema.safeParse(params);
|
||||
if (!parsed.success || !session?.user?.id) {
|
||||
if (!parsed.success) {
|
||||
return await _generateMetadata(
|
||||
(t) => `${t("event_type")}`,
|
||||
() => ""
|
||||
@@ -34,7 +32,6 @@ export const generateMetadata = async ({ params }: _PageProps) => {
|
||||
|
||||
const data = await EventTypeRepository.findTitleById({
|
||||
id: parsed.data.type,
|
||||
userId: session?.user?.id,
|
||||
});
|
||||
|
||||
return await _generateMetadata(
|
||||
|
||||
@@ -441,37 +441,10 @@ export class EventTypeRepository {
|
||||
});
|
||||
}
|
||||
|
||||
static async findTitleById({ id, userId }: { id: number; userId: number }) {
|
||||
return await prisma.eventType.findFirst({
|
||||
static async findTitleById({ id }: { id: number }) {
|
||||
return await prisma.eventType.findUnique({
|
||||
where: {
|
||||
AND: [
|
||||
{
|
||||
OR: [
|
||||
{
|
||||
users: {
|
||||
some: {
|
||||
id: userId,
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
team: {
|
||||
members: {
|
||||
some: {
|
||||
userId: userId,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
userId: userId,
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
id,
|
||||
},
|
||||
],
|
||||
id,
|
||||
},
|
||||
select: {
|
||||
title: true,
|
||||
|
||||
Reference in New Issue
Block a user