From dfea0287db5dcdf84945f7dd7fd87cc1a1fda980 Mon Sep 17 00:00:00 2001 From: zakhy Date: Fri, 2 Aug 2024 08:32:08 +0700 Subject: [PATCH] =?UTF-8?q?=D0=A0=D0=B0=D0=B7=D0=B4=D0=B5=D0=BB=D0=B8?= =?UTF-8?q?=D0=BB=20Celery=20=D0=B7=D0=B0=D0=B4=D0=B0=D1=87=D1=83=20=D0=BF?= =?UTF-8?q?=D0=BE=20=D0=BE=D1=87=D0=B8=D1=81=D1=82=D0=BA=D0=B5=20=D0=91?= =?UTF-8?q?=D0=94=20=D0=BD=D0=B0=20=D0=B4=D0=B2=D0=B5=20=D0=B7=D0=B0=D0=B4?= =?UTF-8?q?=D0=B0=D1=87=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/main/tasks.py | 4 ++-- repcofkk/celery.py | 8 ++++++-- 2 files changed, 8 insertions(+), 4 deletions(-) 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) } }