houses: Leefbaarometer liveability per listing (PDOK geocode + LBM 2024 grid/buurt), min-score filter and sort; store every regional listing (no price caps at scrape time)
All checks were successful
Deploy production / deploy (push) Successful in 2m33s
All checks were successful
Deploy production / deploy (push) Successful in 2m33s
This commit is contained in:
25
scripts/house-liveability.ts
Normal file
25
scripts/house-liveability.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
// (Re)computes Leefbaarometer scores for house.listings. The nightly scrape, the CLI and the
|
||||
// page already score new and changed listings; this is for backfills and a new LBM year.
|
||||
//
|
||||
// bun --env-file=$HOME/.config/house-scrape.env scripts/house-liveability.ts [--force] [--id 12]
|
||||
import postgres from 'postgres';
|
||||
import { scoreListings } from '../src/lib/house-tracker/liveability';
|
||||
|
||||
const args = process.argv.slice(2);
|
||||
const dbUrl = process.env.DB_URL ?? process.env.DATABASE_URL;
|
||||
if (!dbUrl) throw new Error('DB_URL is not set');
|
||||
const sql = postgres(dbUrl, { max: 1, connect_timeout: 10, onnotice: () => {} });
|
||||
const ids = args.includes('--id') ? [Number(args[args.indexOf('--id') + 1])] : undefined;
|
||||
try {
|
||||
const result = await scoreListings(sql, {
|
||||
ids,
|
||||
force: args.includes('--force'),
|
||||
log: (line) => console.log(line)
|
||||
});
|
||||
console.log(
|
||||
`liveability: ${result.checked} checked, ${result.scored} scored, ${result.notFound} without a location, ${result.failed} failed`
|
||||
);
|
||||
if (result.failed) process.exitCode = 1;
|
||||
} finally {
|
||||
await sql.end();
|
||||
}
|
||||
Reference in New Issue
Block a user