forked from CGM_Public/pretix_original
New attempt at improving CheckinList.checkin_count
This commit is contained in:
@@ -3,7 +3,7 @@ from django.db import models
|
|||||||
from django.db.models import Exists, F, Max, OuterRef, Q, Subquery
|
from django.db.models import Exists, F, Max, OuterRef, Q, Subquery
|
||||||
from django.utils.timezone import now
|
from django.utils.timezone import now
|
||||||
from django.utils.translation import gettext_lazy as _, pgettext_lazy
|
from django.utils.translation import gettext_lazy as _, pgettext_lazy
|
||||||
from django_scopes import ScopedManager
|
from django_scopes import ScopedManager, scopes_disabled
|
||||||
from jsonfallback.fields import FallbackJSONField
|
from jsonfallback.fields import FallbackJSONField
|
||||||
|
|
||||||
from pretix.base.models import LoggedModel
|
from pretix.base.models import LoggedModel
|
||||||
@@ -90,6 +90,9 @@ class CheckinList(LoggedModel):
|
|||||||
).count()
|
).count()
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@scopes_disabled()
|
||||||
|
# Disable scopes, because this query is safe and the additional organizer filter in the EXISTS() subquery tricks PostgreSQL into a bad
|
||||||
|
# subplan that sequentially scans all events
|
||||||
def checkin_count(self):
|
def checkin_count(self):
|
||||||
return self.event.cache.get_or_set(
|
return self.event.cache.get_or_set(
|
||||||
'checkin_list_{}_checkin_count'.format(self.pk),
|
'checkin_list_{}_checkin_count'.format(self.pk),
|
||||||
|
|||||||
Reference in New Issue
Block a user