From 14ed3c7ebb856988d0f361c44843a30a29f9cd1d Mon Sep 17 00:00:00 2001 From: Soumyadas15 Date: Tue, 24 Jun 2025 12:49:16 +0530 Subject: [PATCH] fix(billing): fix billing calculation --- backend/services/billing.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/backend/services/billing.py b/backend/services/billing.py index 6111f280..67fa9bb4 100644 --- a/backend/services/billing.py +++ b/backend/services/billing.py @@ -194,6 +194,8 @@ async def calculate_monthly_usage(client, user_id: str) -> float: start_time = datetime.fromisoformat(run['started_at'].replace('Z', '+00:00')).timestamp() if run['completed_at']: end_time = datetime.fromisoformat(run['completed_at'].replace('Z', '+00:00')).timestamp() + if start_time < end_time - 7200: + continue else: # if the start time is more than an hour ago, don't consider that time in total. else use the current time if start_time < now_ts - 3600: