refactor: convert BookingRepository to use dependency injection pattern (#22389)
* refactor: convert BookingRepository to use dependency injection pattern - Add constructor injection for PrismaClient to BookingRepository - Convert all static methods to instance methods using this.prismaClient - Update all usage sites to use two-step instantiation pattern: const bookingRepo = new BookingRepository(prisma); bookingRepo.method(...) - Apply same dependency injection pattern as UserRepository, TeamRepository, and SelectedSlotsRepository - Update test files to use correct prismaMock import paths - Maintain all existing functionality and type safety Files updated: - BookingRepository class structure and all 15 static methods - Video meeting pages and booking views - Booking utilities and services (handleNewBooking, originalRescheduledBookingUtils) - Round robin handlers and reassignment logic - Interval limits and booking limits checking - Test files with proper mocking setup Co-Authored-By: [email protected] <[email protected]> * chore: bump platform libs --------- Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Co-authored-by: [email protected] <[email protected]>
This commit is contained in:
1 parent
80ac118242
commit
c316721051
21 files changed
+124
-88
No files matched your search
@@ -38,7 +38,7 @@
|
||||
"@axiomhq/winston": "^1.2.0",
|
||||
"@calcom/platform-constants": "*",
|
||||
"@calcom/platform-enums": "*",
|
||||
"@calcom/platform-libraries": "npm:@calcom/[email protected]5",
|
||||
"@calcom/platform-libraries": "npm:@calcom/[email protected]6",
|
||||
"@calcom/platform-types": "*",
|
||||
"@calcom/platform-utils": "*",
|
||||
"@calcom/prisma": "*",
|
||||
|
||||
@@ -6,6 +6,7 @@ import { notFound } from "next/navigation";
|
||||
import { z } from "zod";
|
||||
|
||||
import { BookingRepository } from "@calcom/lib/server/repository/booking";
|
||||
import { prisma } from "@calcom/prisma";
|
||||
|
||||
import { buildLegacyCtx } from "@lib/buildLegacyCtx";
|
||||
import { getServerSideProps } from "@lib/video/meeting-not-started/[uid]/getServerSideProps";
|
||||
@@ -22,7 +23,8 @@ export const generateMetadata = async ({ params }: ServerPageProps) => {
|
||||
if (!parsed.success) {
|
||||
notFound();
|
||||
}
|
||||
const booking = await BookingRepository.findBookingByUid({
|
||||
const bookingRepo = new BookingRepository(prisma);
|
||||
const booking = await bookingRepo.findBookingByUid({
|
||||
bookingUid: parsed.data.uid,
|
||||
});
|
||||
|
||||
|
||||
@@ -106,7 +106,8 @@ const checkIfUserIsHost = async ({
|
||||
export async function getServerSideProps(context: GetServerSidePropsContext) {
|
||||
const { req } = context;
|
||||
|
||||
const booking = await BookingRepository.findBookingForMeetingPage({
|
||||
const bookingRepo = new BookingRepository(prisma);
|
||||
const booking = await bookingRepo.findBookingForMeetingPage({
|
||||
bookingUid: context.query.uid as string,
|
||||
});
|
||||
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
import type { GetServerSidePropsContext } from "next";
|
||||
|
||||
import { BookingRepository } from "@calcom/lib/server/repository/booking";
|
||||
import { prisma } from "@calcom/prisma";
|
||||
|
||||
import { type inferSSRProps } from "@lib/types/inferSSRProps";
|
||||
|
||||
export type PageProps = inferSSRProps<typeof getServerSideProps>;
|
||||
export async function getServerSideProps(context: GetServerSidePropsContext) {
|
||||
const booking = await BookingRepository.findBookingForMeetingEndedPage({
|
||||
const bookingRepo = new BookingRepository(prisma);
|
||||
const booking = await bookingRepo.findBookingForMeetingEndedPage({
|
||||
bookingUid: context.query.uid as string,
|
||||
});
|
||||
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
import type { GetServerSidePropsContext } from "next";
|
||||
|
||||
import { BookingRepository } from "@calcom/lib/server/repository/booking";
|
||||
import { prisma } from "@calcom/prisma";
|
||||
|
||||
// change the type
|
||||
export async function getServerSideProps(context: GetServerSidePropsContext) {
|
||||
const booking = await BookingRepository.findBookingByUid({
|
||||
const bookingRepo = new BookingRepository(prisma);
|
||||
const booking = await bookingRepo.findBookingByUid({
|
||||
bookingUid: context.query.uid as string,
|
||||
});
|
||||
|
||||
|
||||
@@ -77,7 +77,8 @@ export async function getServerSideProps(context: GetServerSidePropsContext) {
|
||||
|
||||
let rescheduledToUid: string | null = null;
|
||||
if (bookingInfo.rescheduled) {
|
||||
const rescheduledTo = await BookingRepository.findFirstBookingByReschedule({
|
||||
const bookingRepo = new BookingRepository(prisma);
|
||||
const rescheduledTo = await bookingRepo.findFirstBookingByReschedule({
|
||||
originalBookingUid: bookingInfo.uid,
|
||||
});
|
||||
rescheduledToUid = rescheduledTo?.uid ?? null;
|
||||
@@ -89,7 +90,8 @@ export async function getServerSideProps(context: GetServerSidePropsContext) {
|
||||
} | null = null;
|
||||
|
||||
if (bookingInfo.fromReschedule) {
|
||||
previousBooking = await BookingRepository.findReschedulerByUid({
|
||||
const bookingRepo = new BookingRepository(prisma);
|
||||
previousBooking = await bookingRepo.findReschedulerByUid({
|
||||
uid: bookingInfo.fromReschedule,
|
||||
});
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user