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: