diff --git a/apps/main/tasks.py b/apps/main/tasks.py index 4945d49..16b577c 100644 --- a/apps/main/tasks.py +++ b/apps/main/tasks.py @@ -73,7 +73,7 @@ def create_scales_control_data(): @shared_task -def thin_out_database(): +def thin_out_scales(): positions = Position.objects.all() for position in positions: print(position) @@ -83,9 +83,9 @@ def thin_out_database(): thin_out_scales(position.pred_smena_tag) thin_out_scales(position.month_tag) thin_out_scales(position.sutki_tag) - thin_out_worktime() +@shared_task def thin_out_worktime(): worktime_qs = FabricWorkTime.objects.filter(time__lt=timezone.now() - timedelta(hours=12)).order_by('time') prev = worktime_qs[0] diff --git a/repcofkk/celery.py b/repcofkk/celery.py index 13cdde2..9c15dea 100644 --- a/repcofkk/celery.py +++ b/repcofkk/celery.py @@ -23,8 +23,12 @@ app.conf.beat_schedule = { 'task': 'apps.main.tasks.create_scales_control_data', 'schedule': 30, }, - 'thin_out': { - 'task': 'apps.main.tasks.thin_out_database', + 'thin_out_scales': { + 'task': 'apps.main.tasks.thin_out_scales', 'schedule': crontab(minute=0, hour=0) + }, + 'thin_out_worktime': { + 'task': 'apps.main.tasks.thin_out_worktime', + 'schedule': crontab(minute=0, hour=1) } }