const ADMIN_URL = 'https://ecobeadmin.com/admin/api';
const BOT_TOKEN = '15579990079586356780';

const headers = { 'Authorization': `Bearer ${BOT_TOKEN}` };

async function get(path) {
    const r = await fetch(`${ADMIN_URL}${path}`, { headers });
    if (!r.ok) throw new Error(`${r.status} ${path}`);
    return r.json();
}

async function main() {
    const slugs = await get('/mentees');
    console.log(`\nMentees: ${slugs.length}\n`);

    for (const slug of slugs) {
        let jt;
        try { jt = await get(`/mentee/${slug}/jobtracking`); } catch { continue; }

        const newJobs = (jt.jobs || []).filter(j => j.notifiedAt === null || j.notifiedAt === undefined);
        if (!newJobs.length) continue;

        let cs;
        try { cs = await get(`/mentee/${slug}/career-strategy`); } catch { cs = {}; }
        const name = cs.leadName || slug;

        console.log(`── ${name} (${slug})`);
        console.log(`   ${newJobs.length} new job(s):`);
        for (const j of newJobs) {
            const level = j.aiLevel ? ` [${j.aiLevel}]` : '';
            console.log(`   • ${j.title} @ ${j.company} — ${j.location}${level}`);
            if (j.url) console.log(`     ${j.url}`);
        }
        console.log();
    }
}

main().catch(console.error);
