mirror of
https://github.com/tanrax/django-interactive-frameworks-benchmark
synced 2026-01-10 07:13:36 +01:00
- Create clear_alerts Django management command - Add Ofelia scheduler service to Docker Compose - Configure daily task to run at 3:00 AM - Alerts will be automatically cleared every day
15 lines
354 B
Python
15 lines
354 B
Python
from django.core.management.base import BaseCommand
|
|
|
|
from alerts.models import Alert
|
|
|
|
|
|
class Command(BaseCommand):
|
|
help = 'Clear all alerts from the database'
|
|
|
|
def handle(self, *args, **options):
|
|
count = Alert.objects.all().count()
|
|
Alert.objects.all().delete()
|
|
self.stdout.write(
|
|
self.style.SUCCESS(f'Successfully deleted {count} alerts')
|
|
)
|