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