mirror of
https://github.com/wger-project/wger.git
synced 2026-12-06 07:54:11 +01:00
Schedule the dynamic category catch-all reconcile daily
This commit is contained in:
1 parent
6f6ef36c8c
commit
be593c6dae
1 file changed
+16
@@ -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')
|
||||
|
||||
|
||||
@app.on_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',
|
||||
)
|
||||
Reference in new issue
Block a user