Merge pull request #819 from escapade-mckv/fix-billing

fix(billing): fix billing calculation
This commit is contained in:
Bobbie 2025-06-24 12:50:32 +05:30 committed by GitHub
commit 8f4c6fe17e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
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: