From 006dd10a7958de7e565c766458d8dc60fbc615e5 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Fri, 12 Mar 2021 15:35:33 +1100 Subject: [PATCH] Delete successful tasks more than a month old --- InvenTree/InvenTree/tasks.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/InvenTree/InvenTree/tasks.py b/InvenTree/InvenTree/tasks.py index 985b9e24da..def9abc35d 100644 --- a/InvenTree/InvenTree/tasks.py +++ b/InvenTree/InvenTree/tasks.py @@ -6,6 +6,7 @@ import json import requests import logging +from datetime import datetime, timedelta from django.core.exceptions import AppRegistryNotReady @@ -49,10 +50,16 @@ def heartbeat(): def delete_successful_tasks(): """ Delete successful task logs - which are more than a week old. + which are more than a month old. """ - pass + threshold = datetime.now() - timedelta(days=30) + + results = Success.objects.filter( + started__lte=threshold + ) + + results.delete() def check_for_updates():