You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

17 lines
493 B

from datetime import timedelta
from django.core.management.base import BaseCommand
from django.utils.timezone import now
from hc.api.models import TokenBucket
class Command(BaseCommand):
help = "Prune pings based on limits in user profiles"
def handle(self, *args, **options):
day_ago = now() - timedelta(days=1)
q = TokenBucket.objects.filter(updated__lt=day_ago)
n_pruned, _ = q.delete()
return "Done! Pruned %d token bucket entries" % n_pruned