11import { RedisService } from '@liaoliaots/nestjs-redis' ;
2- import { Injectable , OnApplicationBootstrap } from '@nestjs/common' ;
2+ import { Injectable , Logger , OnApplicationBootstrap } from '@nestjs/common' ;
33import { Cron , SchedulerRegistry } from '@nestjs/schedule' ;
44import { CronJob } from 'cron' ;
55import Redis from 'ioredis' ;
@@ -20,6 +20,7 @@ import { WaitingQueueService } from './waiting-queue.service';
2020@Injectable ( )
2121export class OpenBookingService implements OnApplicationBootstrap {
2222 private readonly redis : Redis | null ;
23+ private readonly logger = new Logger ( OpenBookingService . name ) ;
2324
2425 constructor (
2526 private redisService : RedisService ,
@@ -48,9 +49,13 @@ export class OpenBookingService implements OnApplicationBootstrap {
4849
4950 @Cron ( ONE_MINUTE_BEFORE_THE_HOUR )
5051 async scheduleUpcomingReservations ( ) {
51- const comingEvents = await this . eventRepository . selectUpcomingEvents ( ) ;
52- await this . scheduleUpcomingReservationsToOpen ( comingEvents ) ;
53- await this . scheduleUpcomingReservationsToClose ( comingEvents ) ;
52+ try {
53+ const comingEvents = await this . eventRepository . selectUpcomingEvents ( ) ;
54+ await this . scheduleUpcomingReservationsToOpen ( comingEvents ) ;
55+ await this . scheduleUpcomingReservationsToClose ( comingEvents ) ;
56+ } catch ( error ) {
57+ this . logger . error ( error ) ;
58+ }
5459 }
5560
5661 private async scheduleUpcomingReservationsToOpen ( comingEvents : Event [ ] ) {
0 commit comments