mirror of
https://github.com/pretix/pretix.git
synced 2026-05-05 15:14:04 +00:00
Cache quotas on frontpage shortly under very high load
This commit is contained in:
@@ -778,6 +778,7 @@ class Quota(LoggedModel):
|
||||
now_dt = now_dt or now()
|
||||
res = self._availability(now_dt, count_waitinglist)
|
||||
|
||||
self.event.cache.delete('item_quota_cache')
|
||||
if count_waitinglist and not self.cache_is_hot(now_dt):
|
||||
self.cached_availability_state = res[0]
|
||||
self.cached_availability_number = res[1]
|
||||
|
||||
@@ -70,7 +70,8 @@ def get_grouped_items(event, subevent=None):
|
||||
quotac__gt=0
|
||||
).order_by('category__position', 'category_id', 'position', 'name')
|
||||
display_add_to_cart = False
|
||||
quota_cache = {}
|
||||
external_quota_cache = event.cache.get('item_quota_cache')
|
||||
quota_cache = external_quota_cache or {}
|
||||
|
||||
if subevent:
|
||||
item_price_override = subevent.item_price_overrides
|
||||
@@ -112,6 +113,8 @@ def get_grouped_items(event, subevent=None):
|
||||
v.display_price.gross for v in item.available_variations])
|
||||
item._remove = not bool(item.available_variations)
|
||||
|
||||
if not external_quota_cache:
|
||||
event.cache.set('item_quota_cache', quota_cache, 5)
|
||||
items = [item for item in items
|
||||
if (len(item.available_variations) > 0 or not item.has_variations) and not item._remove]
|
||||
return items, display_add_to_cart
|
||||
|
||||
Reference in New Issue
Block a user