Implementing multiple attempts or failing early if courts are full
This commit is contained in:
parent
c1199b9ec9
commit
3a88831148
1 changed files with 7 additions and 3 deletions
|
|
@ -51,12 +51,14 @@ export class ReservationsWorker {
|
|||
reservation: Reservation,
|
||||
attemptsMade: number,
|
||||
) {
|
||||
if (error instanceof NoCourtAvailableError) {
|
||||
const shouldWaitlist = error instanceof NoCourtAvailableError
|
||||
if (shouldWaitlist) {
|
||||
this.loggerService.warn('No court available')
|
||||
} else {
|
||||
this.loggerService.error('Error while performing reservation', error)
|
||||
}
|
||||
this.loggerService.error('Error while performing reservation', error)
|
||||
if (
|
||||
attemptsMade === DAILY_RESERVATIONS_ATTEMPTS &&
|
||||
(shouldWaitlist || attemptsMade === DAILY_RESERVATIONS_ATTEMPTS) &&
|
||||
!reservation.waitListed
|
||||
) {
|
||||
this.loggerService.log('Adding reservation to waiting list')
|
||||
|
|
@ -66,6 +68,8 @@ export class ReservationsWorker {
|
|||
reservation.dateRangeEnd,
|
||||
)
|
||||
await this.brService.addReservationToWaitList(reservation)
|
||||
} else {
|
||||
throw error
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue