From 832283f029281c7a8c9169bba077c47d4ad34cd9 Mon Sep 17 00:00:00 2001 From: Keannu Bernasol Date: Mon, 6 Nov 2023 21:35:48 +0800 Subject: [PATCH] Fixed pruning command not deleting old study groups --- stude/accounts/management/commands/clean_old_entries.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/stude/accounts/management/commands/clean_old_entries.py b/stude/accounts/management/commands/clean_old_entries.py index 1beb02a..03eaa25 100644 --- a/stude/accounts/management/commands/clean_old_entries.py +++ b/stude/accounts/management/commands/clean_old_entries.py @@ -16,19 +16,17 @@ class Command(BaseCommand): now = timezone.now() # Get the time 8 hours ago - time_threshold = now - timezone.timedelta(hours=4) + time_threshold = now - timezone.timedelta(hours=8) # Get StudyGroup entries older than 8 hours old_groups = StudyGroup.objects.filter(timestamp__lt=time_threshold) - # Log the old groups + # Log the old groups and delete them for group in old_groups: + group.delete() self.stdout.write(self.style.SUCCESS( f'Deleting StudyGroup: {group}')) - # Delete the old groups - old_groups.delete() - # Get StudentStatus entries older than 8 hours old_statuses = StudentStatus.objects.filter(active=True).filter( timestamp__lt=time_threshold)