-
Notifications
You must be signed in to change notification settings - Fork 12.7k
feat(repos): add guest-availability booking + user lookup methods #28908
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2137,4 +2137,54 @@ export class BookingRepository implements IBookingRepository { | |
| }, | ||
| }); | ||
| } | ||
|
|
||
| async findByUidIncludeAttendeeEmails({ uid }: { uid: string }) { | ||
| return this.prismaClient.booking.findUnique({ | ||
| where: { uid }, | ||
| select: { | ||
| id: true, | ||
| uid: true, | ||
| attendees: { select: { email: true } }, | ||
| user: { select: { email: true } }, | ||
| }, | ||
| }); | ||
| } | ||
|
|
||
| async findByUserIdsAndDateRange({ | ||
| userIds, | ||
| userEmails, | ||
| dateFrom, | ||
| dateTo, | ||
| excludeUid, | ||
| }: { | ||
| userIds: number[]; | ||
| userEmails: string[]; | ||
| dateFrom: Date; | ||
| dateTo: Date; | ||
| excludeUid?: string; | ||
| }) { | ||
| if (!userIds.length && !userEmails.length) return []; | ||
|
|
||
| return this.prismaClient.booking.findMany({ | ||
| where: { | ||
| status: { in: [BookingStatus.ACCEPTED, BookingStatus.PENDING] }, | ||
| AND: [{ startTime: { lt: dateTo } }, { endTime: { gt: dateFrom } }], | ||
| OR: [ | ||
| ...(userIds.length > 0 ? [{ userId: { in: userIds } }] : []), | ||
| ...(userEmails.length > 0 | ||
| ? [{ attendees: { some: { email: { in: userEmails, mode: "insensitive" as const } } } }] | ||
| : []), | ||
|
Comment on lines
+2172
to
+2176
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Useful? React with 👍 / 👎. |
||
| ], | ||
| ...(excludeUid ? { uid: { not: excludeUid } } : {}), | ||
| }, | ||
| select: { | ||
| uid: true, | ||
| startTime: true, | ||
| endTime: true, | ||
| title: true, | ||
| userId: true, | ||
| status: true, | ||
| }, | ||
| }); | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
findByUidIncludeAttendeeEmailsonly selectsuser.email, so when a booking has no related user row (theBooking.userIdrelation is nullable and other codepaths already handle missing user data), this method returns no organizer email at all. That makes downstream reschedule logic unable to reliably determine host-vs-guest initiator for those bookings; selectinguserPrimaryEmail(or an equivalent fallback) here would avoid dropping host identity.Useful? React with 👍 / 👎.