import dotenv from 'dotenv'; import path from 'path'; dotenv.config({ path: path.resolve(process.cwd(), '.env.local') }); dotenv.config({ path: path.resolve(process.cwd(), '.env') }); import { Pool } from 'pg'; const pool = new Pool({ connectionString: process.env.DATABASE_URL }); async function main() { const totalRes = await pool.query(`SELECT COUNT(*) as total FROM churches WHERE source = 'osm'`); console.log('Total OSM churches:', totalRes.rows[0].total); const countryRes = await pool.query(`SELECT country, COUNT(*) as count FROM churches WHERE source = 'osm' AND country IS NOT NULL GROUP BY country ORDER BY count DESC LIMIT 40`); console.log('\nTop 40 countries by OSM church count:'); for (const row of countryRes.rows) { console.log(` ${row.country}: ${row.count}`); } // Check key countries that were under-imported const keyCountries = ['AT','HR','UA','RO','LV','BY','RS','BA','MK','AL','EE','GE','AM','RU','IN','JP','CA','US','MX','AR','CO','ID','CN']; const keyRes = await pool.query(`SELECT country, COUNT(*) as count FROM churches WHERE source = 'osm' AND country = ANY($1) GROUP BY country ORDER BY count DESC`, [keyCountries]); console.log('\nKey countries to check (were under-imported):'); const found = new Map(keyRes.rows.map((r: any) => [r.country, r.count])); for (const c of keyCountries) { console.log(` ${c}: ${found.get(c) || 0}`); } // Total countries const countriesRes = await pool.query(`SELECT COUNT(DISTINCT country) as total FROM churches WHERE source = 'osm'`); console.log(`\nTotal countries with OSM data: ${countriesRes.rows[0].total}`); await pool.end(); } main();