import { KEYWORDS } from "../config.ts"; import type { SearchConfig } from "../config.ts"; import { fetchJobs, isEnglishContent } from "../fetch.ts"; import { readFileSync } from "fs"; const csv = readFileSync("./results/jobs.csv", "utf8"); const existingIds = new Set( [...csv.matchAll(/jobs\/view\/(\d+)\//g)].map((m) => m[1]) ); const searches: SearchConfig[] = [ { label: "Zürich (city)", keywords: KEYWORDS, geoId: "102436504", location: "Zürich, Switzerland", workType: ["onsite", "hybrid"], timePosted: "month", }, { label: "Zürich Metropolitan Area", keywords: KEYWORDS, geoId: "107814425", location: "Zürich Metropolitan Area", workType: ["onsite", "hybrid"], timePosted: "month", }, { label: "Zürich Area", keywords: KEYWORDS, geoId: "90009888", location: "Zürich Area", workType: ["onsite", "hybrid"], timePosted: "month", }, ]; const seen = new Set(); const allJobs = []; for (const cfg of searches) { const jobs = await fetchJobs(cfg); for (const j of jobs) { if (seen.has(j.id) || existingIds.has(j.id)) continue; seen.add(j.id); allJobs.push(j); } } console.log(`\n${allJobs.length} new Zürich jobs. Checking English content…\n`); const results = []; for (const j of allJobs) { process.stdout.write(` ${j.title} — ${j.company} … `); const ok = await isEnglishContent(j.id); console.log(ok ? "ok" : "dropped (non-English)"); if (ok) results.push(j); } console.log(`\n=== ${results.length} new English Zürich jobs ===\n`); for (const j of results) { console.log(`${j.title} | ${j.company} | ${j.link}`); }