require('dotenv').config();
const { createClient } = require('@supabase/supabase-js');
const sb = createClient(process.env.SUPABASE_URL, process.env.SUPABASE_SERVICE_KEY);
(async()=>{
  const {data} = await sb.from('tasks')
    .select('id,title,source,created_at,status')
    .eq('status','open')
    .order('title',{ascending:true});
  
  const seen = {};
  const dupes = [];
  for(const t of data){
    if(seen[t.title]){
      dupes.push(t.id);
      console.log('DUPE:',t.id,'|',t.source,'|',t.title.slice(0,60));
    } else {
      seen[t.title] = t.id;
    }
  }
  console.log('\nTotal dupes:',dupes.length);
})();
