Skip to content

Commit

Permalink
perf: no need for two query fetches for d link (private booking page) (
Browse files Browse the repository at this point in the history
…#18659)

* return eventData

* use eventData and do not do extra query fetch
  • Loading branch information
hbjORbj authored Jan 14, 2025
1 parent 5366044 commit 501c49f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 17 deletions.
22 changes: 5 additions & 17 deletions apps/web/app/d/[link]/[slug]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ import { _generateMetadata } from "app/_utils";
import { WithLayout } from "app/layoutHOC";
import { cookies, headers } from "next/headers";

import { orgDomainConfig } from "@calcom/features/ee/organizations/lib/orgDomains";
import { EventRepository } from "@calcom/lib/server/repository/event";

import { buildLegacyCtx } from "@lib/buildLegacyCtx";
import { getServerSideProps } from "@lib/d/[link]/[slug]/getServerSideProps";
import { type PageProps } from "@lib/d/[link]/[slug]/getServerSideProps";
Expand All @@ -17,24 +14,15 @@ export const generateMetadata = async ({ params, searchParams }: _PageProps) =>
const legacyCtx = buildLegacyCtx(headers(), cookies(), params, searchParams);
const pageProps = await getData(legacyCtx);

const { booking, user: username, slug: eventSlug, isTeamEvent } = pageProps;
const { booking, eventData, isBrandingHidden } = pageProps;
const rescheduleUid = booking?.uid;
const { currentOrgDomain, isValidOrgDomain } = orgDomainConfig(legacyCtx.req);
const org = isValidOrgDomain ? currentOrgDomain : null;

const event = await EventRepository.getPublicEvent({
username,
eventSlug,
isTeamEvent,
org,
fromRedirectOfNonOrgLink: legacyCtx.query.orgRedirection === "true",
});

const profileName = event?.profile?.name ?? "";
const title = event?.title ?? "";
const profileName = eventData?.profile?.name ?? "";
const title = eventData?.title ?? "";
return await _generateMetadata(
(t) => `${rescheduleUid && !!booking ? t("reschedule") : ""} ${title} | ${profileName}`,
(t) => `${rescheduleUid ? t("reschedule") : ""} ${title}`
(t) => `${rescheduleUid ? t("reschedule") : ""} ${title}`,
isBrandingHidden
);
};

Expand Down
1 change: 1 addition & 0 deletions apps/web/lib/d/[link]/[slug]/getServerSideProps.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ async function getUserPageProps(context: GetServerSidePropsContext) {

return {
props: {
eventData,
entity: eventData.entity,
duration: getMultipleDurationValue(
eventData.metadata?.multipleDuration,
Expand Down

0 comments on commit 501c49f

Please sign in to comment.