← back to Nationalrealestate

src/ingest/commercial/engine.ts

25 lines

/**
 * Commercial-layer ingest dispatcher: npm run ingest:commercial -- <county>
 * Counties: la (LA County assessor sqlite -> commercial_parcel). More CA counties
 * (san-diego, orange, sf, ...) register here as their adapters are added.
 */
import { pool } from '../../../db/pool.ts';

const ADAPTERS: Record<string, () => Promise<{ run: () => Promise<{ upserted: number }> }>> = {
  la: async () => ({ run: (await import('./la_assessor.ts')).ingestLaCommercial }),
};

async function main() {
  const which = (process.argv[2] || '').toLowerCase();
  if (!ADAPTERS[which]) {
    console.error(`usage: npm run ingest:commercial -- <${Object.keys(ADAPTERS).join('|')}>`);
    process.exit(2);
  }
  const { run } = await ADAPTERS[which]();
  const { upserted } = await run();
  console.log(`[commercial:${which}] done, ${upserted} upserted`);
  await pool.end();
}

main().catch(e => { console.error(e); process.exit(1); });