Update routes/subscription.py
Browse files- routes/subscription.py +3 -3
routes/subscription.py
CHANGED
@@ -62,15 +62,15 @@ class CreatePriceRequest(BaseModel):
|
|
62 |
|
63 |
def get_active_subscribers_by_price_id(price_id: str) -> list:
|
64 |
"""
|
65 |
-
Retorna uma lista de
|
66 |
"""
|
67 |
response = requests.get(
|
68 |
-
f"{SUPABASE_URL}/rest/v1/Subscriptions?price_id=eq.{price_id}&select=
|
69 |
headers=SUPABASE_ROLE_HEADERS
|
70 |
)
|
71 |
if response.status_code == 200:
|
72 |
data = response.json()
|
73 |
-
return [entry["
|
74 |
logger.warning(f"⚠️ Failed to fetch subscribers: {response.status_code} - {response.text}")
|
75 |
return []
|
76 |
|
|
|
62 |
|
63 |
def get_active_subscribers_by_price_id(price_id: str) -> list:
|
64 |
"""
|
65 |
+
Retorna uma lista de customer_ids que têm uma assinatura ativa com o price_id fornecido.
|
66 |
"""
|
67 |
response = requests.get(
|
68 |
+
f"{SUPABASE_URL}/rest/v1/Subscriptions?price_id=eq.{price_id}&active=eq.true&select=customer_id",
|
69 |
headers=SUPABASE_ROLE_HEADERS
|
70 |
)
|
71 |
if response.status_code == 200:
|
72 |
data = response.json()
|
73 |
+
return [entry["customer_id"] for entry in data if "customer_id" in entry]
|
74 |
logger.warning(f"⚠️ Failed to fetch subscribers: {response.status_code} - {response.text}")
|
75 |
return []
|
76 |
|