mirror of
https://github.com/pretix/pretix.git
synced 2026-09-12 16:04:42 +00:00
sendmail: fix quadratic checkin query
This commit is contained in:
@@ -373,24 +373,38 @@ class OrderSendView(BaseSenderView):
|
||||
opq = opq.alias(
|
||||
any_checkins=Exists(
|
||||
Checkin.all.filter(
|
||||
Q(position_id=OuterRef('pk')) | Q(position__addon_to_id=OuterRef('pk')),
|
||||
position_id=OuterRef('pk'),
|
||||
successful=True,
|
||||
list__consider_tickets_used=True,
|
||||
)
|
||||
) | Exists(
|
||||
Checkin.all.filter(
|
||||
position__addon_to_id=OuterRef('pk'),
|
||||
successful=True,
|
||||
list__consider_tickets_used=True,
|
||||
)
|
||||
)
|
||||
)
|
||||
ql.append(Q(any_checkins=False))
|
||||
|
||||
if form.cleaned_data.get('checkin_lists'):
|
||||
opq = opq.alias(
|
||||
matching_checkins=Exists(
|
||||
Checkin.all.filter(
|
||||
Q(position_id=OuterRef('pk')) | Q(position__addon_to_id=OuterRef('pk')),
|
||||
position_id=OuterRef('pk'),
|
||||
list_id__in=[i.pk for i in form.cleaned_data.get('checkin_lists', [])],
|
||||
successful=True
|
||||
)
|
||||
) | Exists(
|
||||
Checkin.all.filter(
|
||||
position__addon_to_id=OuterRef('pk'),
|
||||
list_id__in=[i.pk for i in form.cleaned_data.get('checkin_lists', [])],
|
||||
successful=True
|
||||
)
|
||||
)
|
||||
)
|
||||
ql.append(Q(matching_checkins=True))
|
||||
|
||||
if len(ql) == 2:
|
||||
opq = opq.filter(ql[0] | ql[1])
|
||||
elif ql:
|
||||
|
||||
Reference in New Issue
Block a user