Feature/parallel booking availability (#3087)

This commit is contained in:
Omar López authored and GitHub committed 2022-06-19 16:02:00 +01:00
1 parent 7599f2384e
commit 2d28ca61a4
21 files changed
+242 -121

No files matched your search

@@ -1,10 +1,10 @@
import {
BookingStatus,
User,
Booking,
Attendee,
Booking,
BookingReference,
BookingStatus,
EventType,
User,
WebhookTriggerEvents,
} from "@prisma/client";
import dayjs from "dayjs";
@@ -13,7 +13,7 @@ import { getSession } from "next-auth/react";
import type { TFunction } from "next-i18next";
import { z, ZodError } from "zod";
import { getCalendar } from "@calcom/core/CalendarManager";
import { getCalendar } from "@calcom/app-store/_utils/getCalendar";
import { CalendarEventBuilder } from "@calcom/core/builders/CalendarEvent/builder";
import { CalendarEventDirector } from "@calcom/core/builders/CalendarEvent/director";
import { deleteMeeting } from "@calcom/core/videoClient";
+1 -1
View File
@@ -3,8 +3,8 @@ import async from "async";
import dayjs from "dayjs";
import { NextApiRequest, NextApiResponse } from "next";
import { getCalendar } from "@calcom/app-store/_utils/getCalendar";
import { FAKE_DAILY_CREDENTIAL } from "@calcom/app-store/dailyvideo/lib/VideoApiAdapter";
import { getCalendar } from "@calcom/core/CalendarManager";
import { deleteMeeting } from "@calcom/core/videoClient";
import { sendCancelledEmails } from "@calcom/emails";
import { isPrismaObjOrUndefined, parseRecurringEvent } from "@calcom/lib";
+19 -3
View File
@@ -29,7 +29,23 @@ export default trpcNext.createNextApiHandler({
/**
* @link https://trpc.io/docs/caching#api-response-caching
*/
// responseMeta() {
// // ...
// },
responseMeta({ ctx, paths, type, errors }) {
// assuming we have all our public routes in `viewer.public`
const allPublic = paths && paths.every((path) => path.startsWith("viewer.public."));
// checking that no procedures errored
const allOk = errors.length === 0;
// checking we're doing a query request
const isQuery = type === "query";
if (allPublic && allOk && isQuery) {
// cache request for 1 day + revalidate once every 5 seconds
const ONE_DAY_IN_SECONDS = 60 * 60 * 24;
return {
headers: {
"cache-control": `s-maxage=5, stale-while-revalidate=${ONE_DAY_IN_SECONDS}`,
},
};
}
return {};
},
});