Removing monitor and screenshotting from flow for now
This commit is contained in:
parent
d23358e5d8
commit
c7e500ad6f
2 changed files with 6 additions and 38 deletions
|
|
@ -43,14 +43,13 @@ export class ReservationsWorker {
|
||||||
reservation.dateRangeStart,
|
reservation.dateRangeStart,
|
||||||
reservation.dateRangeEnd,
|
reservation.dateRangeEnd,
|
||||||
)
|
)
|
||||||
await this.performReservation(reservation, job.attemptsMade, false)
|
await this.performReservation(reservation, job.attemptsMade)
|
||||||
}
|
}
|
||||||
|
|
||||||
private async handleReservationErrors(
|
private async handleReservationErrors(
|
||||||
error: Error,
|
error: Error,
|
||||||
reservation: Reservation,
|
reservation: Reservation,
|
||||||
attemptsMade: number,
|
attemptsMade: number,
|
||||||
timeSensitive = true,
|
|
||||||
) {
|
) {
|
||||||
const shouldWaitlist = error instanceof NoCourtAvailableError
|
const shouldWaitlist = error instanceof NoCourtAvailableError
|
||||||
if (shouldWaitlist) {
|
if (shouldWaitlist) {
|
||||||
|
|
@ -68,17 +67,13 @@ export class ReservationsWorker {
|
||||||
reservation.dateRangeStart,
|
reservation.dateRangeStart,
|
||||||
reservation.dateRangeEnd,
|
reservation.dateRangeEnd,
|
||||||
)
|
)
|
||||||
await this.addReservationToWaitList(reservation, timeSensitive)
|
await this.addReservationToWaitList(reservation)
|
||||||
} else {
|
} else {
|
||||||
throw error
|
throw error
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async performReservation(
|
async performReservation(reservation: Reservation, attemptsMade: number) {
|
||||||
reservation: Reservation,
|
|
||||||
attemptsMade: number,
|
|
||||||
timeSensitive = true,
|
|
||||||
) {
|
|
||||||
try {
|
try {
|
||||||
await this.brService.performReservation(reservation)
|
await this.brService.performReservation(reservation)
|
||||||
await this.reservationsService.deleteById(reservation.id)
|
await this.reservationsService.deleteById(reservation.id)
|
||||||
|
|
@ -87,19 +82,14 @@ export class ReservationsWorker {
|
||||||
error as Error,
|
error as Error,
|
||||||
reservation,
|
reservation,
|
||||||
attemptsMade,
|
attemptsMade,
|
||||||
timeSensitive,
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async addReservationToWaitList(
|
async addReservationToWaitList(reservation: Reservation) {
|
||||||
reservation: Reservation,
|
|
||||||
timeSensitive = true,
|
|
||||||
) {
|
|
||||||
try {
|
try {
|
||||||
const waitingListId = await this.brService.addReservationToWaitList(
|
const waitingListId = await this.brService.addReservationToWaitList(
|
||||||
reservation,
|
reservation,
|
||||||
timeSensitive,
|
|
||||||
)
|
)
|
||||||
await this.reservationsService.update(reservation.id, {
|
await this.reservationsService.update(reservation.id, {
|
||||||
waitListed: true,
|
waitListed: true,
|
||||||
|
|
|
||||||
|
|
@ -116,18 +116,6 @@ export class BaanReserverenService {
|
||||||
return TYPING_DELAY_MS
|
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
|
// Check session by going to /reservations to see if we are still logged in via cookies
|
||||||
private async checkSession(username: string) {
|
private async checkSession(username: string) {
|
||||||
this.loggerService.debug('Checking session', {
|
this.loggerService.debug('Checking session', {
|
||||||
|
|
@ -565,28 +553,20 @@ export class BaanReserverenService {
|
||||||
return courtStatuses
|
return courtStatuses
|
||||||
}
|
}
|
||||||
|
|
||||||
public async performReservation(
|
public async performReservation(reservation: Reservation) {
|
||||||
reservation: Reservation,
|
|
||||||
timeSensitive = true,
|
|
||||||
) {
|
|
||||||
try {
|
try {
|
||||||
await this.init()
|
await this.init()
|
||||||
await this.navigateToDay(reservation.dateRangeStart)
|
await this.navigateToDay(reservation.dateRangeStart)
|
||||||
await this.monitorCourtReservations()
|
|
||||||
await this.selectAvailableTime(reservation)
|
await this.selectAvailableTime(reservation)
|
||||||
await this.selectOwner(reservation.ownerId)
|
await this.selectOwner(reservation.ownerId)
|
||||||
await this.selectOpponents(reservation.opponents)
|
await this.selectOpponents(reservation.opponents)
|
||||||
await this.confirmReservation()
|
await this.confirmReservation()
|
||||||
} catch (error: unknown) {
|
} catch (error: unknown) {
|
||||||
if (!timeSensitive) await this.handleError()
|
|
||||||
throw error
|
throw error
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async addReservationToWaitList(
|
public async addReservationToWaitList(reservation: Reservation) {
|
||||||
reservation: Reservation,
|
|
||||||
timeSensitive = true,
|
|
||||||
) {
|
|
||||||
try {
|
try {
|
||||||
await this.init()
|
await this.init()
|
||||||
await this.navigateToWaitingList()
|
await this.navigateToWaitingList()
|
||||||
|
|
@ -609,7 +589,6 @@ export class BaanReserverenService {
|
||||||
|
|
||||||
return waitingListId
|
return waitingListId
|
||||||
} catch (error: unknown) {
|
} catch (error: unknown) {
|
||||||
if (!timeSensitive) await this.handleError()
|
|
||||||
throw error
|
throw error
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -621,7 +600,6 @@ export class BaanReserverenService {
|
||||||
await this.navigateToWaitingList()
|
await this.navigateToWaitingList()
|
||||||
await this.deleteWaitingListEntryRowById(reservation.waitingListId)
|
await this.deleteWaitingListEntryRowById(reservation.waitingListId)
|
||||||
} catch (error: unknown) {
|
} catch (error: unknown) {
|
||||||
await this.handleError()
|
|
||||||
throw error
|
throw error
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue