#!/usr/bin/env bun import { searches } from "../config.ts"; import { fetchJobs, isEnglishContent } from "../fetch.ts"; const CSV = "./results/jobs.csv"; const BASEL_LABELS = new Set(["Basel (city)", "Basel Metropolitan Area", "Basel-Country"]); const existingIds = new Set(); try { const text = await Bun.file(CSV).text(); for (const line of text.split("\n").slice(1)) { const id = line.match(/\/jobs\/view\/(\d+)\//)?.[1]; if (id) existingIds.add(id); } } catch { /* first run */ } type Row = { id: string; title: string; company: string; location: string; link: string; posted: string; isNew: boolean }; const seen = new Set(); const rows: Row[] = []; for (const config of searches.filter((s) => BASEL_LABELS.has(s.label))) { const jobs = await fetchJobs(config); console.error(`[${config.label}] ${jobs.length} jobs`); for (const job of jobs) { if (seen.has(job.id)) continue; seen.add(job.id); rows.push({ id: job.id, title: job.title, company: job.company, location: (job as any).location ?? "", link: job.link, posted: (job as any).postedAt ?? "", isNew: !existingIds.has(job.id), }); } } const survivors: Row[] = []; for (const r of rows) { if (await isEnglishContent(r.id)) survivors.push(r); else console.error(` DE/FR content dropped: ${r.title} — ${r.company}`); } console.error(`\n${survivors.length} survivors (${survivors.filter((r) => r.isNew).length} new)`); console.log(JSON.stringify(survivors, null, 2));