mirror of
https://github.com/lemeow125/StudE-Backend.git
synced 2024-11-16 22:09:25 +08:00
Fixed pruning command not deleting old study groups
This commit is contained in:
parent
ef8ac8c28c
commit
832283f029
1 changed files with 3 additions and 5 deletions
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue