Removing monitor and screenshotting from flow for now

This commit is contained in:
Collin Duncan 2024-04-16 09:17:52 +02:00
parent d23358e5d8
commit c7e500ad6f
No known key found for this signature in database
2 changed files with 6 additions and 38 deletions

View file

@ -43,14 +43,13 @@ export class ReservationsWorker {
reservation.dateRangeStart,
reservation.dateRangeEnd,
)
await this.performReservation(reservation, job.attemptsMade, false)
await this.performReservation(reservation, job.attemptsMade)
}
private async handleReservationErrors(
error: Error,
reservation: Reservation,
attemptsMade: number,
timeSensitive = true,
) {
const shouldWaitlist = error instanceof NoCourtAvailableError
if (shouldWaitlist) {
@ -68,17 +67,13 @@ export class ReservationsWorker {
reservation.dateRangeStart,
reservation.dateRangeEnd,
)
await this.addReservationToWaitList(reservation, timeSensitive)
await this.addReservationToWaitList(reservation)
} else {
throw error
}
}
async performReservation(
reservation: Reservation,
attemptsMade: number,
timeSensitive = true,
) {
async performReservation(reservation: Reservation, attemptsMade: number) {
try {
await this.brService.performReservation(reservation)
await this.reservationsService.deleteById(reservation.id)
@ -87,19 +82,14 @@ export class ReservationsWorker {
error as Error,
reservation,
attemptsMade,
timeSensitive,
)
}
}
async addReservationToWaitList(
reservation: Reservation,
timeSensitive = true,
) {
async addReservationToWaitList(reservation: Reservation) {
try {
const waitingListId = await this.brService.addReservationToWaitList(
reservation,
timeSensitive,
)
await this.reservationsService.update(reservation.id, {
waitListed: true,

View file

@ -116,18 +116,6 @@ export class BaanReserverenService {
return TYPING_DELAY_MS
}
private async handleError() {
await this.page
.screenshot({
type: 'jpeg',
path: `./${Date.now()}_error-screenshot.jpeg`,
quality: 50,
})
.catch((reason: any) =>
this.loggerService.warn('Failed to take screenshot', { reason }),
)
}
// Check session by going to /reservations to see if we are still logged in via cookies
private async checkSession(username: string) {
this.loggerService.debug('Checking session', {
@ -565,28 +553,20 @@ export class BaanReserverenService {
return courtStatuses
}
public async performReservation(
reservation: Reservation,
timeSensitive = true,
) {
public async performReservation(reservation: Reservation) {
try {
await this.init()
await this.navigateToDay(reservation.dateRangeStart)
await this.monitorCourtReservations()
await this.selectAvailableTime(reservation)
await this.selectOwner(reservation.ownerId)
await this.selectOpponents(reservation.opponents)
await this.confirmReservation()
} catch (error: unknown) {
if (!timeSensitive) await this.handleError()
throw error
}
}
public async addReservationToWaitList(
reservation: Reservation,
timeSensitive = true,
) {
public async addReservationToWaitList(reservation: Reservation) {
try {
await this.init()
await this.navigateToWaitingList()
@ -609,7 +589,6 @@ export class BaanReserverenService {
return waitingListId
} catch (error: unknown) {
if (!timeSensitive) await this.handleError()
throw error
}
}
@ -621,7 +600,6 @@ export class BaanReserverenService {
await this.navigateToWaitingList()
await this.deleteWaitingListEntryRowById(reservation.waitingListId)
} catch (error: unknown) {
await this.handleError()
throw error
}
}