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