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,
|
reservation: Reservation,
|
||||||
attemptsMade: number,
|
attemptsMade: number,
|
||||||
) {
|
) {
|
||||||
if (error instanceof NoCourtAvailableError) {
|
const shouldWaitlist = error instanceof NoCourtAvailableError
|
||||||
|
if (shouldWaitlist) {
|
||||||
this.loggerService.warn('No court available')
|
this.loggerService.warn('No court available')
|
||||||
|
} else {
|
||||||
|
this.loggerService.error('Error while performing reservation', error)
|
||||||
}
|
}
|
||||||
this.loggerService.error('Error while performing reservation', error)
|
|
||||||
if (
|
if (
|
||||||
attemptsMade === DAILY_RESERVATIONS_ATTEMPTS &&
|
(shouldWaitlist || attemptsMade === DAILY_RESERVATIONS_ATTEMPTS) &&
|
||||||
!reservation.waitListed
|
!reservation.waitListed
|
||||||
) {
|
) {
|
||||||
this.loggerService.log('Adding reservation to waiting list')
|
this.loggerService.log('Adding reservation to waiting list')
|
||||||
|
|
@ -66,6 +68,8 @@ export class ReservationsWorker {
|
||||||
reservation.dateRangeEnd,
|
reservation.dateRangeEnd,
|
||||||
)
|
)
|
||||||
await this.brService.addReservationToWaitList(reservation)
|
await this.brService.addReservationToWaitList(reservation)
|
||||||
|
} else {
|
||||||
|
throw error
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue