import { Pool } from 'pg'; const pool = new Pool({ connectionString: process.env.DATABASE_URL }); async function main() { const c = await pool.connect(); const total = await c.query('SELECT count(*) FROM "Church"'); console.log('\n=== DATABASE OVERVIEW ==='); console.log('Churches total:', Number(total.rows[0].count).toLocaleString()); const withWebsite = await c.query('SELECT count(*) FROM "Church" WHERE website IS NOT NULL'); console.log('With website:', Number(withWebsite.rows[0].count).toLocaleString()); const withSchedules = await c.query('SELECT count(DISTINCT "churchId") FROM "MassSchedule"'); console.log('With mass schedules:', Number(withSchedules.rows[0].count).toLocaleString()); const enrichedGoogle = await c.query('SELECT count(*) FROM "Church" WHERE "googlePlaceId" IS NOT NULL'); console.log('Google Places enriched:', Number(enrichedGoogle.rows[0].count).toLocaleString()); const totalSchedules = await c.query('SELECT count(*) FROM "MassSchedule"'); console.log('Total mass schedules:', Number(totalSchedules.rows[0].count).toLocaleString()); const countries = await c.query('SELECT country, count(*) as cnt FROM "Church" GROUP BY country ORDER BY cnt DESC LIMIT 15'); console.log('\n=== TOP COUNTRIES ==='); for (const r of countries.rows) console.log(' ' + (r.country || '(null)') + ':', Number(r.cnt).toLocaleString()); const sources = await c.query('SELECT source, count(*) as cnt FROM "Church" GROUP BY source ORDER BY cnt DESC LIMIT 10'); console.log('\n=== CHURCH SOURCES ==='); for (const r of sources.rows) console.log(' ' + (r.source || '(null)') + ':', Number(r.cnt).toLocaleString()); const lastScrape = await c.query('SELECT "lastScrapedAt" FROM "Church" WHERE "lastScrapedAt" IS NOT NULL ORDER BY "lastScrapedAt" DESC LIMIT 1'); console.log('\n=== LAST SCRAPE ==='); console.log(lastScrape.rows[0]?.lastScrapedAt || 'No scrapes yet'); const jobs = await c.query('SELECT status, count(*) as cnt FROM "ScrapeJob" GROUP BY status ORDER BY cnt DESC'); console.log('\n=== JOB STATUS ==='); for (const r of jobs.rows) console.log(' ' + r.status + ':', Number(r.cnt).toLocaleString()); const schedulesByLang = await c.query('SELECT language, count(*) as cnt FROM "MassSchedule" GROUP BY language ORDER BY cnt DESC LIMIT 10'); console.log('\n=== SCHEDULES BY LANGUAGE ==='); for (const r of schedulesByLang.rows) console.log(' ' + (r.language || '(null)') + ':', Number(r.cnt).toLocaleString()); c.release(); await pool.end(); } main().catch(e => { console.error(e.message); process.exit(1); });