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.

16 lines
426 B

  1. from django.core.management.base import BaseCommand
  2. from hc.api.models import Flip
  3. from hc.lib.date import month_boundaries
  4. class Command(BaseCommand):
  5. help = "Prune old Flip objects."
  6. def handle(self, *args, **options):
  7. threshold = min(month_boundaries(months=3))
  8. q = Flip.objects.filter(created__lt=threshold)
  9. n_pruned, _ = q.delete()
  10. return "Done! Pruned %d flips." % n_pruned