Public Access
1
0

chore: improve postal data import observability

Add progress logging and a status script for postal imports and neighbor builds, and ignore local raw and generated postal datasets.
This commit is contained in:
pguerrerox
2026-04-12 23:22:36 +00:00
parent cc00a439bf
commit dc7686f507
11 changed files with 267 additions and 23 deletions
+41
View File
@@ -0,0 +1,41 @@
import { getDbPool } from '../../server/src/db/pool.js';
import { createScriptLogger } from './postal-logging.js';
async function run() {
const logger = createScriptLogger('postal-status');
const pool = getDbPool();
try {
const postalAreasByCountry = await pool.query<{ country_code: string; area_count: string }>(`
select country_code, count(*)::text as area_count
from public.postal_areas
group by country_code
order by country_code asc
`);
const neighborCountsByCountry = await pool.query<{ country_code: string; neighbor_count: string }>(`
select area.country_code, count(*)::text as neighbor_count
from public.postal_area_neighbors link
join public.postal_areas area on area.id = link.postal_area_id
group by area.country_code
order by area.country_code asc
`);
const totalAreas = await pool.query<{ count: string }>('select count(*)::text as count from public.postal_areas');
const totalNeighbors = await pool.query<{ count: string }>('select count(*)::text as count from public.postal_area_neighbors');
logger.info(`Postal areas loaded: ${totalAreas.rows[0]?.count ?? '0'}`);
postalAreasByCountry.rows.forEach((row) => {
logger.info(` ${row.country_code}: ${row.area_count} postal areas`);
});
logger.info(`Postal neighbor links built: ${totalNeighbors.rows[0]?.count ?? '0'}`);
neighborCountsByCountry.rows.forEach((row) => {
logger.info(` ${row.country_code}: ${row.neighbor_count} adjacency links`);
});
} finally {
await pool.end();
}
}
await run();