require('dotenv').config();
const s=require('@supabase/supabase-js').createClient(process.env.SUPABASE_URL,process.env.SUPABASE_SERVICE_KEY);
(async()=>{
  const {data:subs}=await s.from('submissions').select('id, status, task:task_id(title, budget), worker:worker_id(username)').in('status',['pending','in_progress','accepted']);
  console.log('Active submissions:', subs?.length || 0);
  if(subs) subs.forEach(x=>console.log(' ',x.status,'|',x.task?.title?.slice(0,40),'| V'+x.task?.budget,'|',x.worker?.username));
  const {data:tasks}=await s.from('tasks').select('title, budget, status, worker_count').eq('status','active');
  console.log('\nActive tasks (accepted by workers):', tasks?.length || 0);
  let total=0;
  if(tasks) tasks.forEach(t=>{
    console.log(' ',t.title?.slice(0,40),'| V'+t.budget,'| workers:',t.worker_count);
    total+=t.budget;
  });
  console.log('Total budget in active tasks:', total);
})();
