feat: add task for cleaning up procrastinate jobs after 1 month

This commit is contained in:
Herculino Trotta
2024-10-17 00:36:31 -03:00
parent fde5101011
commit 2affd39c7b
4 changed files with 103 additions and 0 deletions

14
app/apps/common/tasks.py Normal file
View File

@@ -0,0 +1,14 @@
from procrastinate import builtin_tasks
from procrastinate.contrib.django import app
@app.periodic(cron="0 4 * * *")
@app.task(queueing_lock="remove_old_jobs", pass_context=True)
async def remove_old_jobs(context, timestamp):
return await builtin_tasks.remove_old_jobs(
context,
max_hours=744,
remove_error=True,
remove_cancelled=True,
remove_aborted=True,
)