mirror of
https://github.com/pretix/pretix.git
synced 2026-05-06 15:24:02 +00:00
Reduce queries for waitinglist autoassign n+1 (PRETIXEU-BJJ) (#5819)
* baseline of 574 queries * reuse event from wle for locked_wle reduces amount of queries to 556 * keep event accross refresh from db drops queries from 556 to 471, halving the amount of queries for direct fetches for the event * make numbers of queries reproducible by prewarming ContentTypeCache * fix oversight * correct number of queries to 335 * remove debug tooling * remove assert_num_queries
This commit is contained in:
committed by
GitHub
parent
112d5da792
commit
a900e11ce0
@@ -159,6 +159,7 @@ class WaitingListEntry(LoggedModel):
|
||||
if availability[1] is None or availability[1] < 1:
|
||||
raise WaitingListException(_('This product is currently not available.'))
|
||||
|
||||
event = self.event
|
||||
ev = self.subevent or self.event
|
||||
if ev.seat_category_mappings.filter(product=self.item).exists():
|
||||
# Generally, we advertise the waiting list to be based on quotas only. This makes it dangerous
|
||||
@@ -191,6 +192,7 @@ class WaitingListEntry(LoggedModel):
|
||||
|
||||
with transaction.atomic():
|
||||
locked_wle = WaitingListEntry.objects.select_for_update(of=OF_SELF).get(pk=self.pk)
|
||||
locked_wle.event = event
|
||||
if locked_wle.voucher:
|
||||
raise WaitingListException(_('A voucher has already been sent to this person.'))
|
||||
e = locked_wle.email
|
||||
@@ -227,6 +229,7 @@ class WaitingListEntry(LoggedModel):
|
||||
locked_wle.save()
|
||||
|
||||
self.refresh_from_db()
|
||||
self.event = event
|
||||
|
||||
with language(self.locale, self.event.settings.region):
|
||||
self.send_mail(
|
||||
|
||||
Reference in New Issue
Block a user