Skip to content

Commit

Permalink
Merge pull request #332 from makerspace/db/discount-coupon-query-less
Browse files Browse the repository at this point in the history
Query only the discount coupon that is asked for instead of all
  • Loading branch information
BerglundDaniel authored Nov 2, 2023
2 parents 6b0e8d8 + a248636 commit 3ff7c2f
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions api/src/shop/stripe_discounts.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class Discount:
fraction_off: Decimal


DISCOUNT_FRACTIONS: Optional[Dict[PriceLevel, Discount]] = None
DISCOUNT_FRACTIONS: Optional[Dict[PriceLevel, Discount]] = {price_level: None for price_level in PriceLevel}


def get_price_level_for_member(member: "Member") -> PriceLevel:
Expand All @@ -38,10 +38,8 @@ def get_discount_for_product(product: "Product", price_level: PriceLevel) -> Dis


def get_discount_fraction_off(price_level: PriceLevel) -> Discount:
global DISCOUNT_FRACTIONS
if DISCOUNT_FRACTIONS is None:
DISCOUNT_FRACTIONS = {price_level: _query_discount_fraction_off(price_level) for price_level in PriceLevel}

if DISCOUNT_FRACTIONS[price_level] is None:
DISCOUNT_FRACTIONS[price_level] = _query_discount_fraction_off(price_level)
return DISCOUNT_FRACTIONS[price_level]


Expand Down

0 comments on commit 3ff7c2f

Please sign in to comment.