mirror of https://github.com/kortix-ai/suna.git
fix frontend time calculation
This commit is contained in:
parent
3128a8197b
commit
bfbfbfb823
|
@ -35,10 +35,19 @@ export default async function AccountBillingStatus({ accountId, returnUrl }: Pro
|
||||||
const startOfMonth = new Date();
|
const startOfMonth = new Date();
|
||||||
startOfMonth.setDate(1);
|
startOfMonth.setDate(1);
|
||||||
startOfMonth.setHours(0, 0, 0, 0);
|
startOfMonth.setHours(0, 0, 0, 0);
|
||||||
|
// First get threads for this account
|
||||||
|
const { data: threadsData } = await supabaseClient
|
||||||
|
.from('threads')
|
||||||
|
.select('thread_id')
|
||||||
|
.eq('account_id', accountId);
|
||||||
|
|
||||||
|
const threadIds = threadsData?.map(t => t.thread_id) || [];
|
||||||
|
|
||||||
|
// Then get agent runs for those threads
|
||||||
const { data: agentRunData, error: agentRunError } = await supabaseClient
|
const { data: agentRunData, error: agentRunError } = await supabaseClient
|
||||||
.from('agent_runs')
|
.from('agent_runs')
|
||||||
.select('started_at, completed_at')
|
.select('started_at, completed_at')
|
||||||
|
.in('thread_id', threadIds)
|
||||||
.gte('started_at', startOfMonth.toISOString());
|
.gte('started_at', startOfMonth.toISOString());
|
||||||
|
|
||||||
let totalSeconds = 0;
|
let totalSeconds = 0;
|
||||||
|
|
Loading…
Reference in New Issue