Adding a delay to the monitoring during court reservation

This commit is contained in:
Collin Duncan 2024-04-04 18:05:05 +02:00
parent bac0e3971d
commit ca3e374d19
No known key found for this signature in database
2 changed files with 7 additions and 6 deletions

View file

@ -4,8 +4,6 @@ import { Cron, CronExpression } from '@nestjs/schedule'
import dayjs from '../common/dayjs' import dayjs from '../common/dayjs'
import { LoggerService } from '../logger/service.logger' import { LoggerService } from '../logger/service.logger'
import { MONITORING_QUEUE_NAME, MonitoringQueue } from '../monitoring/config'
import { MonitorType } from '../monitoring/entity'
import { NtfyProvider } from '../ntfy/provider' import { NtfyProvider } from '../ntfy/provider'
import { BaanReserverenService } from '../runner/baanreserveren/service' import { BaanReserverenService } from '../runner/baanreserveren/service'
import { RESERVATIONS_QUEUE_NAME, ReservationsQueue } from './config' import { RESERVATIONS_QUEUE_NAME, ReservationsQueue } from './config'

View file

@ -606,10 +606,13 @@ export class BaanReserverenService {
await this.navigateToDay(date) await this.navigateToDay(date)
} }
const statuses = await this.getAllCourtStatuses() const statuses = await this.getAllCourtStatuses()
await this.monitoringQueue.add({ await this.monitoringQueue.add(
type: MonitorType.CourtReservations, {
data: statuses, type: MonitorType.CourtReservations,
}) data: statuses,
},
{ delay: 60 * 1000 },
)
} catch (error: unknown) { } catch (error: unknown) {
this.loggerService.error( this.loggerService.error(
`Failed to monitor court reservations: ${(error as Error).message}`, `Failed to monitor court reservations: ${(error as Error).message}`,