Skip to content
Snippets Groups Projects
Unverified Commit 5918c954 authored by john-metabase's avatar john-metabase Committed by GitHub
Browse files

Updates stats job to run at a random time of day (#19828)

Thanks for the review/approvals.
parent ac609499
No related branches found
No related tags found
No related merge requests found
......@@ -24,13 +24,16 @@
(defmethod task/init! ::SendAnonymousUsageStats
[_]
(let [job (jobs/build
(jobs/of-type SendAnonymousUsageStats)
(jobs/with-identity (jobs/key job-key)))
trigger (triggers/build
(triggers/with-identity (triggers/key trigger-key))
(triggers/start-now)
(triggers/with-schedule
;; run twice a day
(cron/cron-schedule "0 15 7 * * ? *")))]
(let [job (jobs/build
(jobs/of-type SendAnonymousUsageStats)
(jobs/with-identity (jobs/key job-key)))
;; run at a random hour/minute
schedule (cron/cron-schedule
(format "0 %d %d * * ? *"
(rand-int 60)
(rand-int 24)))
trigger (triggers/build
(triggers/with-identity (triggers/key trigger-key))
(triggers/start-now)
(triggers/with-schedule schedule))]
(task/schedule-task! job trigger)))
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment