Enable Data Fetch logging with log=1 param (#2042)

pull/2026/head^2
hariombalhara 2022-03-04 15:33:10 +05:30 committed by GitHub
parent 7384675b6b
commit 6687544e66
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 2 deletions

View File

@ -123,7 +123,7 @@ export const getServerSideProps = async (context: GetServerSidePropsContext) =>
const ssr = await ssrInit(context);
const username = (context.query.user as string).toLowerCase();
const dataFetchStart = Date.now();
const user = await prisma.user.findUnique({
where: {
username: username.toLowerCase(),
@ -205,7 +205,10 @@ export const getServerSideProps = async (context: GetServerSidePropsContext) =>
},
take: user.plan === "FREE" ? 1 : undefined,
});
const dataFetchEnd = Date.now();
if (context.query.log === "1") {
context.res.setHeader("X-Data-Fetch-Time", `${dataFetchEnd - dataFetchStart}ms`);
}
const eventTypesRaw = eventTypesWithHidden.filter((evt) => !evt.hidden);
const eventTypes = eventTypesRaw.map((eventType) => ({