mirror of
https://github.com/pretix/pretix.git
synced 2026-05-09 15:54:03 +00:00
Reduce SQL query load on check-in list viewer
This commit is contained in:
@@ -35,7 +35,7 @@
|
|||||||
import dateutil.parser
|
import dateutil.parser
|
||||||
from django.contrib import messages
|
from django.contrib import messages
|
||||||
from django.db import transaction
|
from django.db import transaction
|
||||||
from django.db.models import Exists, Max, OuterRef, Subquery
|
from django.db.models import Exists, Max, OuterRef, Prefetch, Subquery
|
||||||
from django.http import Http404, HttpResponseRedirect
|
from django.http import Http404, HttpResponseRedirect
|
||||||
from django.shortcuts import get_object_or_404, redirect
|
from django.shortcuts import get_object_or_404, redirect
|
||||||
from django.urls import reverse
|
from django.urls import reverse
|
||||||
@@ -87,7 +87,11 @@ class CheckInListShow(EventPermissionRequiredMixin, PaginationMixin, ListView):
|
|||||||
auto_checked_in=Exists(
|
auto_checked_in=Exists(
|
||||||
Checkin.objects.filter(position_id=OuterRef('pk'), list_id=self.list.pk, auto_checked_in=True)
|
Checkin.objects.filter(position_id=OuterRef('pk'), list_id=self.list.pk, auto_checked_in=True)
|
||||||
)
|
)
|
||||||
).select_related('item', 'variation', 'order', 'addon_to')
|
).select_related(
|
||||||
|
'item', 'variation', 'order', 'addon_to'
|
||||||
|
).prefetch_related(
|
||||||
|
Prefetch('subevent', queryset=self.request.event.subevents.all())
|
||||||
|
)
|
||||||
if self.list.subevent:
|
if self.list.subevent:
|
||||||
qs = qs.filter(
|
qs = qs.filter(
|
||||||
subevent=self.list.subevent
|
subevent=self.list.subevent
|
||||||
|
|||||||
Reference in New Issue
Block a user