events: notification_cleanup: avoid unnecessary loop (#12417)

This commit is contained in:
Marc 'risson' Schmitt
2024-12-19 18:20:04 +01:00
committed by GitHub
parent 7763a3673c
commit e265ee253b

View File

@ -138,7 +138,6 @@ def notification_cleanup(self: SystemTask):
"""Cleanup seen notifications and notifications whose event expired."""
notifications = Notification.objects.filter(Q(event=None) | Q(seen=True))
amount = notifications.count()
for notification in notifications:
notification.delete()
notifications.delete()
LOGGER.debug("Expired notifications", amount=amount)
self.set_status(TaskStatus.SUCCESSFUL, f"Expired {amount} Notifications")