From bd7a38ea3f665057481e3c4ac38f61756b6bcb29 Mon Sep 17 00:00:00 2001 From: Raphael Michel Date: Wed, 12 May 2021 21:05:30 +0200 Subject: [PATCH] Waiting list: Cronjob should skip events with no waiting entries (#2066) * Waiting list: Cronjob should skip events with no waiting entries * isort --- src/pretix/base/services/waitinglist.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/pretix/base/services/waitinglist.py b/src/pretix/base/services/waitinglist.py index 8162bf1396..601ef2e56f 100644 --- a/src/pretix/base/services/waitinglist.py +++ b/src/pretix/base/services/waitinglist.py @@ -22,7 +22,7 @@ import sys from datetime import timedelta -from django.db.models import Q +from django.db.models import Exists, OuterRef, Q from django.dispatch import receiver from django.utils.timezone import now from django_scopes import scopes_disabled @@ -101,6 +101,12 @@ def assign_automatically(event: Event, user_id: int=None, subevent_id: int=None) @scopes_disabled() def process_waitinglist(sender, **kwargs): qs = Event.objects.filter( + Exists( + WaitingListEntry.objects.filter( + event_id=OuterRef('pk'), + voucher__isnull=True, + ) + ), live=True ).exclude( Q(date_to__isnull=True) | Q(date_to__lt=now() - timedelta(days=14)),