tasks.py 507 B

1234567891011121314
  1. from datetime import timedelta
  2. from django.utils.timezone import now
  3. from django.conf import settings
  4. from celery import shared_task
  5. from .models import TransactionEvent
  6. @shared_task
  7. def cleanup_old_transaction_events():
  8. """ Delete older events and associated data """
  9. days = settings.GLITCHTIP_MAX_EVENT_LIFE_DAYS
  10. qs = TransactionEvent.objects.filter(created__lt=now() - timedelta(days=days))
  11. # Fast bulk delete - see https://code.djangoproject.com/ticket/9519
  12. qs._raw_delete(qs.db)