From ac25fbab549982e3fbda5bc8f6a5325055ad5515 Mon Sep 17 00:00:00 2001 From: "gcp-cherry-pick-bot[bot]" <98988430+gcp-cherry-pick-bot[bot]@users.noreply.github.com> Date: Thu, 19 Dec 2024 18:49:30 +0100 Subject: [PATCH] events: notification_cleanup: avoid unnecessary loop (cherry-pick #12417) (#12418) events: notification_cleanup: avoid unnecessary loop (#12417) Co-authored-by: Marc 'risson' Schmitt --- authentik/events/tasks.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/authentik/events/tasks.py b/authentik/events/tasks.py index 0989dc8b5d..d923b068b5 100644 --- a/authentik/events/tasks.py +++ b/authentik/events/tasks.py @@ -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")