chore: Remove passing optional prisma select prop to Repository classes (#16600)

This commit is contained in:
Benny Joo authored and GitHub committed 2024-09-11 18:14:19 -07:00
1 parent 4a59841b02
commit 55e1e0fa3d
7 files changed
+81 -61

No files matched your search

+61 -8
View File
@@ -113,18 +113,71 @@ export class BookingRepository {
return allBookings;
}
static async findBookingByUidWithOptionalSelect({
bookingUid,
select,
}: {
bookingUid: string;
select?: Prisma.BookingSelect;
}) {
static async findBookingByUid({ bookingUid }: { bookingUid: string }) {
return await prisma.booking.findUnique({
where: {
uid: bookingUid,
},
select: { ...bookingMinimalSelect, ...select },
select: bookingMinimalSelect,
});
}
static async findBookingForMeetingPage({ bookingUid }: { bookingUid: string }) {
return await prisma.booking.findUnique({
where: {
uid: bookingUid,
},
select: {
...bookingMinimalSelect,
uid: true,
description: true,
isRecorded: true,
user: {
select: {
id: true,
timeZone: true,
name: true,
email: true,
username: true,
},
},
references: {
select: {
id: true,
uid: true,
type: true,
meetingUrl: true,
meetingPassword: true,
},
where: {
type: "daily_video",
},
},
},
});
}
static async findBookingForMeetingEndedPage({ bookingUid }: { bookingUid: string }) {
return await prisma.booking.findUnique({
where: {
uid: bookingUid,
},
select: {
...bookingMinimalSelect,
uid: true,
user: {
select: {
credentials: true,
},
},
references: {
select: {
uid: true,
type: true,
meetingUrl: true,
},
},
},
});
}
+14 -2
View File
@@ -239,12 +239,12 @@ export class UserRepository {
};
}
static async findById({ id, select }: { id: number; select?: Prisma.UserSelect }) {
static async findById({ id }: { id: number }) {
const user = await prisma.user.findUnique({
where: {
id,
},
select: { ...userSelect, ...select },
select: userSelect,
});
if (!user) {
@@ -566,6 +566,18 @@ export class UserRepository {
return teamIds;
}
static async getTimeZoneAndDefaultScheduleId({ userId }: { userId: number }) {
return await prisma.user.findUnique({
where: {
id: userId,
},
select: {
timeZone: true,
defaultScheduleId: true,
},
});
}
static async adminFindById(userId: number) {
return await prisma.user.findUniqueOrThrow({
where: {