diff --git a/src/schedules/EventWatchSchedule.ts b/src/schedules/EventWatchSchedule.ts index ed0c4c6..c010942 100644 --- a/src/schedules/EventWatchSchedule.ts +++ b/src/schedules/EventWatchSchedule.ts @@ -6,11 +6,16 @@ import { diffArrays } from '../utils/common'; import { sendNotification } from '../utils/firebase-admin'; import { prisma } from '../prisma/db'; import type { Schedule } from './schedule'; +import dayjs from 'dayjs'; export class EventWatchSchedule implements Schedule { + + #job?: nodeSchedule.Job; + constructor() {} async watchEvents() { + console.debug('nextStartTime: %s', dayjs(this.#job?.nextInvocation()).format('YYYY-MM-DD HH:mm:ss')); const events = await EventSubscribeService.getAllEvents(); events.forEach((e) => this.diffEvent(e)); } @@ -56,10 +61,11 @@ export class EventWatchSchedule implements Schedule { await Promise.all(tokens.map(token => sendNotification(token, { title, body, url }))); } start() { - const schedule = nodeSchedule.scheduleJob('event-watch', { + const job = nodeSchedule.scheduleJob('event-watch', { minute: [0, 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55], hour: new nodeSchedule.Range(7, 23), }, () => this.watchEvents()); - console.debug('Start schedule:', schedule.name); + this.#job = job; + console.debug('Start schedule: %s, next run at %s', job.name, dayjs(job.nextInvocation()).format('YYYY-MM-DD HH:mm:ss')); } } \ No newline at end of file