From cad640af119d6ccf01a2d4bad102ba21140308e3 Mon Sep 17 00:00:00 2001 From: Hiroshi Nishio Date: Mon, 4 Nov 2024 10:18:42 -0800 Subject: [PATCH] Update free tier usage amount to 3 from 5 and refactor minor things --- config.py | 2 +- services/stripe/customer.py | 2 +- services/supabase/users_manager.py | 4 +--- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/config.py b/config.py index c1ac635a..530b38ff 100644 --- a/config.py +++ b/config.py @@ -81,7 +81,7 @@ def get_env_var(name: str) -> str: ENV: str = get_env_var(name="ENV") IS_PRD: bool = ENV == "prod" # Update here too: https://dashboard.stripe.com/test/products/prod_PokLGIxiVUwCi6 -FREE_TIER_REQUEST_AMOUNT = 5 +FREE_TIER_REQUEST_AMOUNT = 3 ISSUE_NUMBER_FORMAT = "/issue-" # DO NOT USE "#" as it is a special character and has to be encoded in URL, like in GitHub API URL MAX_RETRIES = 3 PER_PAGE = 100 diff --git a/services/stripe/customer.py b/services/stripe/customer.py index cc9e3cd2..d62121d9 100644 --- a/services/stripe/customer.py +++ b/services/stripe/customer.py @@ -56,7 +56,7 @@ def get_subscription(customer_id: str) -> stripe.ListObject[stripe.Subscription] @handle_exceptions(default_return_value=FREE_TIER_REQUEST_AMOUNT, raise_on_error=False) -def get_request_count_from_product_id_metadata(product_id: str) -> int: +def get_request_count_from_product_id_metadata(product_id: str): """ https://docs.stripe.com/api/products/retrieve?lang=python https://dashboard.stripe.com/test/products/prod_PqZFpCs1Jq6X4E diff --git a/services/supabase/users_manager.py b/services/supabase/users_manager.py index 2bd60fe3..e4833c77 100644 --- a/services/supabase/users_manager.py +++ b/services/supabase/users_manager.py @@ -179,9 +179,7 @@ def get_how_many_requests_left_and_cycle( stripe_customer_id: str = data[1][0]["owners"]["stripe_customer_id"] - subscription = get_subscription( - customer_id=stripe_customer_id, - ) + subscription = get_subscription(customer_id=stripe_customer_id) start_date_seconds, end_date_seconds, product_id = ( self.parse_subscription_object(