Browse Source
Feature/randomize minutes of hourly data gathering cron job (#5403)
* Randomize minutes of hourly data gathering
* Update changelog
pull/5021/merge
Thomas Kaul
4 days ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with
4 additions and
2 deletions
-
CHANGELOG.md
-
apps/api/src/services/cron/cron.service.ts
|
@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 |
|
|
|
|
|
|
|
|
### Changed |
|
|
### Changed |
|
|
|
|
|
|
|
|
|
|
|
- Randomized the minutes of the hourly data gathering cron job |
|
|
- Refactored the dialog footer component to standalone |
|
|
- Refactored the dialog footer component to standalone |
|
|
- Refactored the dialog header component to standalone |
|
|
- Refactored the dialog header component to standalone |
|
|
- Refactored the landing page to standalone |
|
|
- Refactored the landing page to standalone |
|
|
|
@ -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(); |
|
|
} |
|
|
} |
|
|