fix(billing): fix billing calculation

This commit is contained in:
Soumyadas15 2025-06-24 12:49:16 +05:30
parent a1fc73070f
commit 14ed3c7ebb
1 changed files with 2 additions and 0 deletions

View File

@ -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: