|
|
@ -17,6 +17,7 @@ import { Cron, CronExpression } from '@nestjs/schedule'; |
|
|
|
|
|
|
|
|
@Injectable() |
|
|
@Injectable() |
|
|
export class CronService { |
|
|
export class CronService { |
|
|
|
|
|
private static readonly EVERY_HOUR_AT_RANDOM_MINUTE = `${new Date().getMinutes()} * * * *`; |
|
|
private static readonly EVERY_SUNDAY_AT_LUNCH_TIME = '0 12 * * 0'; |
|
|
private static readonly EVERY_SUNDAY_AT_LUNCH_TIME = '0 12 * * 0'; |
|
|
|
|
|
|
|
|
public constructor( |
|
|
public constructor( |
|
|
@ -28,8 +29,8 @@ export class CronService { |
|
|
private readonly userService: UserService |
|
|
private readonly userService: UserService |
|
|
) {} |
|
|
) {} |
|
|
|
|
|
|
|
|
@Cron(CronExpression.EVERY_HOUR) |
|
|
@Cron(CronService.EVERY_HOUR_AT_RANDOM_MINUTE) |
|
|
public async runEveryHour() { |
|
|
public async runEveryHourAtRandomMinute() { |
|
|
if (await this.isDataGatheringEnabled()) { |
|
|
if (await this.isDataGatheringEnabled()) { |
|
|
await this.dataGatheringService.gather7Days(); |
|
|
await this.dataGatheringService.gather7Days(); |
|
|
} |
|
|
} |
|
|
|