Skip to content

armgit / wger

Public Imported from GitHub
0

Self hosted FLOSS fitness/workout, nutrition and weight tracker

Schedule the dynamic category catch-all reconcile daily

Roland Geiderbe593c6daeff
diff --git a/wger/measurements/tasks.py b/wger/measurements/tasks.py
index 412d5400c..139ff8f79 100644
--- a/wger/measurements/tasks.py
+++ b/wger/measurements/tasks.py
@@ -15,6 +15,10 @@
# Standard Library
import logging
+import random
+
+# Third Party
+from celery.schedules import crontab
# wger
from wger.celery_configuration import app
@@ -47,3 +51,15 @@ def reconcile_all_dynamic_categories_task():
reconcile(category)
count += 1
logger.info(f'Reconciled {count} dynamic measurement categories')
+
+
[email protected]_after_finalize.connect
+def setup_periodic_tasks(sender, **kwargs):
+ sender.add_periodic_task(
+ crontab(
+ hour=str(random.randint(0, 23)),
+ minute=str(random.randint(0, 59)),
+ ),
+ reconcile_all_dynamic_categories_task.s(),
+ name='Reconcile dynamic measurement categories',
+ )