Files
Andros Fenollosa 5b95bb87b0 Add scheduled task to clear alerts daily
- 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
2025-12-13 10:40:15 +01:00

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')
)