django-orchestra-test/orchestra/contrib/orchestration/tasks.py

16 lines
437 B
Python
Raw Normal View History

2015-04-27 14:54:17 +00:00
from datetime import timedelta
2015-04-20 14:23:10 +00:00
from celery.task.schedules import crontab
from django.utils import timezone
2015-05-03 17:44:46 +00:00
from orchestra.contrib.tasks import periodic_task
2015-04-20 14:23:10 +00:00
from .models import BackendLog
2015-05-05 19:42:55 +00:00
@periodic_task(run_every=crontab(hour=7, minute=0))
def backend_logs_cleanup():
2015-04-27 14:54:17 +00:00
days = settings.ORCHESTRATION_BACKEND_CLEANUP_DAYS
epoch = timezone.now()-timedelta(days=days)
2015-04-20 14:23:10 +00:00
BackendLog.objects.filter(created_at__lt=epoch).delete()