// Bereitet die Einzelprüfung aller Adressen vor, die der automatische Filter nicht bestätigt hat. // Ergebnis: daten/einzelpruefung/stapel-.json import { mkdirSync, readFileSync, writeFileSync } from 'node:fs'; import { dirname, join } from 'node:path'; import { fileURLToPath } from 'node:url'; const hier = dirname(fileURLToPath(import.meta.url)); const pfad = (d) => join(hier, 'daten', d); const STAPEL = 8; const zeilen = readFileSync(pfad('gemeinden-hosting.jsonl'), 'utf8').trim().split('\n').map((z) => JSON.parse(z)).filter((z) => z.inhalt !== 'bestaetigt'); const proHost = new Map(); for (const z of zeilen) { if (!proHost.has(z.host)) proHost.set(z.host, { host: z.host, ziel: z.ziel, filtergrund: z.inhalt, einwohner: 0, gemeinden: [] }); const e = proHost.get(z.host); e.einwohner += z.einwohner ?? 0; e.gemeinden.push({ ags: z.ags, kreis: z.ags.slice(0, 5), name: z.name }); } const liste = [...proHost.values()].sort((a, b) => b.einwohner - a.einwohner); mkdirSync(pfad('einzelpruefung'), { recursive: true }); for (let s = 0; s < STAPEL; s++) writeFileSync(pfad(`einzelpruefung/stapel-${s + 1}.json`), JSON.stringify(liste.filter((_, i) => i % STAPEL === s), null, 1)); console.log(JSON.stringify({ adressen: liste.length, gemeinden: zeilen.length, jeStapel: Math.ceil(liste.length / STAPEL) }));