From ca3e374d192d4ada26eac5e7af7b1dec9494961a Mon Sep 17 00:00:00 2001 From: Collin Duncan <3679940+cgduncan7@users.noreply.github.com> Date: Thu, 4 Apr 2024 18:05:05 +0200 Subject: [PATCH] Adding a delay to the monitoring during court reservation --- src/reservations/cron.ts | 2 -- src/runner/baanreserveren/service.ts | 11 +++++++---- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/reservations/cron.ts b/src/reservations/cron.ts index a716003..e46ce7e 100644 --- a/src/reservations/cron.ts +++ b/src/reservations/cron.ts @@ -4,8 +4,6 @@ import { Cron, CronExpression } from '@nestjs/schedule' import dayjs from '../common/dayjs' 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 { BaanReserverenService } from '../runner/baanreserveren/service' import { RESERVATIONS_QUEUE_NAME, ReservationsQueue } from './config' diff --git a/src/runner/baanreserveren/service.ts b/src/runner/baanreserveren/service.ts index 09cfdac..6f93569 100644 --- a/src/runner/baanreserveren/service.ts +++ b/src/runner/baanreserveren/service.ts @@ -606,10 +606,13 @@ export class BaanReserverenService { await this.navigateToDay(date) } const statuses = await this.getAllCourtStatuses() - await this.monitoringQueue.add({ - type: MonitorType.CourtReservations, - data: statuses, - }) + await this.monitoringQueue.add( + { + type: MonitorType.CourtReservations, + data: statuses, + }, + { delay: 60 * 1000 }, + ) } catch (error: unknown) { this.loggerService.error( `Failed to monitor court reservations: ${(error as Error).message}`,