Разделил Celery задачу по очистке БД на две задачи
This commit is contained in:
parent
3a689e9dd0
commit
dfea0287db
@ -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]
|
||||
|
||||
@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user