Premature optimization indeed is the root of all evil

This commit is contained in:
Raphael Michel
2015-02-19 23:50:58 +01:00
parent 0fb7875c98
commit 89a5c65df7

View File

@@ -1215,7 +1215,6 @@ class Quota(Versionable):
# TODO: Test for interference with old versions of Item-Quota-relations, etc.
# TODO: Prevent corner-cases like people having ordered an item before it got
# its first variationsadded
cache = self.event.get_cache()
quotalookup = (
( # Orders for items which do not have any variations
Q(variation__isnull=True)
@@ -1225,13 +1224,10 @@ class Quota(Versionable):
)
)
paid_orders = cache.get('quota_paid_%s' % self.identity)
if paid_orders is None:
paid_orders = OrderPosition.objects.current.filter(
Q(order__status=Order.STATUS_PAID)
& quotalookup
).count()
cache.set('quota_paid_%s' % self.identity, paid_orders)
paid_orders = OrderPosition.objects.current.filter(
Q(order__status=Order.STATUS_PAID)
& quotalookup
).count()
if paid_orders >= self.size:
return Quota.AVAILABILITY_GONE, 0
@@ -1296,7 +1292,6 @@ class Quota(Versionable):
)
self.locked_here = None
self.locked = None
self.event.get_cache().delete('quota_paid_%s' % self.identity)
return updated