mirror of
https://github.com/pretix/pretix.git
synced 2026-05-07 15:34:02 +00:00
Fix: keep is_business heuristic result for a longer time (Z#23126061) (#3582)
This commit is contained in:
@@ -1144,13 +1144,10 @@ class QuestionsStep(QuestionsViewMixin, CartMixin, TemplateFlowStep):
|
|||||||
|
|
||||||
def _get_is_business_heuristic(self):
|
def _get_is_business_heuristic(self):
|
||||||
key = 'checkout_heuristic_is_business:' + str(self.event.pk)
|
key = 'checkout_heuristic_is_business:' + str(self.event.pk)
|
||||||
cached_result = caches['default'].get(key)
|
cached_result = caches['default'].get(key, default=False)
|
||||||
if cached_result is None:
|
if caches['default'].add(key + ':valid', True, timeout=10): # set valid while query is running
|
||||||
if caches['default'].add(key, False, timeout=10): # return False while query is running
|
QuestionsStep._update_is_business_heuristic.apply_async(args=(self.event.pk,))
|
||||||
QuestionsStep._update_is_business_heuristic.apply_async(args=(self.event.pk,))
|
return cached_result
|
||||||
return False
|
|
||||||
else:
|
|
||||||
return cached_result
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@app.task(base=EventTask)
|
@app.task(base=EventTask)
|
||||||
@@ -1165,7 +1162,8 @@ class QuestionsStep(QuestionsViewMixin, CartMixin, TemplateFlowStep):
|
|||||||
else:
|
else:
|
||||||
is_business = False
|
is_business = False
|
||||||
key = 'checkout_heuristic_is_business:' + str(event.pk)
|
key = 'checkout_heuristic_is_business:' + str(event.pk)
|
||||||
caches['default'].set(key, is_business, timeout=12 * 3600) # 12 hours
|
caches['default'].set(key, is_business, timeout=30 * 24 * 3600) # store result for 30 days
|
||||||
|
caches['default'].set(key + ':valid', True, timeout=12 * 3600) # but recalculate after 12 hours
|
||||||
|
|
||||||
|
|
||||||
class PaymentStep(CartMixin, TemplateFlowStep):
|
class PaymentStep(CartMixin, TemplateFlowStep):
|
||||||
|
|||||||
Reference in New Issue
Block a user