Pēteris Caune
1 year ago
No known key found for this signature in database
GPG Key ID: E28D7679E9A9EDE2
1 changed files with
3 additions and
1 deletions
-
hc/api/management/commands/pruneflips.py
|
|
@ -1,5 +1,7 @@ |
|
|
|
from __future__ import annotations |
|
|
|
|
|
|
|
from datetime import timedelta as td |
|
|
|
|
|
|
|
from django.core.management.base import BaseCommand |
|
|
|
|
|
|
|
from hc.api.models import Flip |
|
|
@ -10,7 +12,7 @@ class Command(BaseCommand): |
|
|
|
help = "Prune old Flip objects." |
|
|
|
|
|
|
|
def handle(self, *args, **options): |
|
|
|
threshold = min(month_boundaries(months=3)) |
|
|
|
threshold = min(month_boundaries(3, "UTC")) - td(days=1) |
|
|
|
|
|
|
|
q = Flip.objects.filter(created__lt=threshold) |
|
|
|
n_pruned, _ = q.delete() |
|
|
|