From a6aa0691cdac1e0861b4a074f181452d90c7ac54 Mon Sep 17 00:00:00 2001 From: Wei He Date: Tue, 19 Nov 2024 01:53:47 +0000 Subject: [PATCH] feat: increase cron schedule to every 8 hours --- src/utils/helpers.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/utils/helpers.ts b/src/utils/helpers.ts index 6178b16e7..8677847f9 100644 --- a/src/utils/helpers.ts +++ b/src/utils/helpers.ts @@ -1,9 +1,12 @@ import { appConfig } from "@/src/configs/app-config.ts"; export const getRandomCronSchedule = () => { + // Every 8 hours at a random minute const randomMinute = Math.floor(Math.random() * 60); - const randomHour = Math.floor(Math.random() * 24); - return `${randomMinute} ${randomHour} * * *`; + const randomHour1 = Math.floor(Math.random() * 8); + const randomHour2 = randomHour1 + 8; + const randomHour3 = randomHour2 + 8; + return `${randomMinute} ${randomHour1},${randomHour2},${randomHour3} * * *`; }; export const timeout = (ms: number): Promise =>