pandora/pandora/log/tasks.py

17 lines
429 B
Python
Raw Normal View History

2013-01-12 08:20:22 +00:00
# -*- coding: utf-8 -*-
2013-01-12 08:20:22 +00:00
from datetime import timedelta, datetime
2021-12-15 19:22:49 +00:00
from app.celery import app
from celery.schedules import crontab
2013-01-12 08:20:22 +00:00
from . import models
2013-01-12 08:20:22 +00:00
2021-12-15 19:22:49 +00:00
@app.task(queue='encoding')
2013-01-12 08:20:22 +00:00
def cronjob(**kwargs):
models.Log.objects.filter(modified__lt=datetime.now()-timedelta(days=30)).delete()
2021-12-15 19:22:49 +00:00
@app.on_after_finalize.connect
def setup_periodic_tasks(sender, **kwargs):
sender.add_periodic_task(timedelta(days=1), cronjob.s())