From b2867b1955cd647234b4025c8d6f61a9d0b6925a Mon Sep 17 00:00:00 2001 From: Thomas Kaul <4159106+dtslvr@users.noreply.github.com> Date: Mon, 25 Aug 2025 21:45:13 +0200 Subject: [PATCH] Feature/randomize minutes of hourly data gathering cron job (#5403) * Randomize minutes of hourly data gathering * Update changelog --- CHANGELOG.md | 1 + apps/api/src/services/cron/cron.service.ts | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1797d94ab..da75dde40 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed +- Randomized the minutes of the hourly data gathering cron job - Refactored the dialog footer component to standalone - Refactored the dialog header component to standalone - Refactored the landing page to standalone diff --git a/apps/api/src/services/cron/cron.service.ts b/apps/api/src/services/cron/cron.service.ts index b770aa2d7..88fcabce2 100644 --- a/apps/api/src/services/cron/cron.service.ts +++ b/apps/api/src/services/cron/cron.service.ts @@ -17,6 +17,7 @@ import { Cron, CronExpression } from '@nestjs/schedule'; @Injectable() 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'; public constructor( @@ -28,8 +29,8 @@ export class CronService { private readonly userService: UserService ) {} - @Cron(CronExpression.EVERY_HOUR) - public async runEveryHour() { + @Cron(CronService.EVERY_HOUR_AT_RANDOM_MINUTE) + public async runEveryHourAtRandomMinute() { if (await this.isDataGatheringEnabled()) { await this.dataGatheringService.gather7Days(); }