Reset local main to gitea/master (new source of truth) and restored local-only files: web scrapers, admin dashboard, ChromaDB integration, debug scripts, and utility libraries that aren't tracked in Gitea. Gitea master adds: discovermass, buscarmisas-network, hk-parishes, bohosluzby, kerknet, gottesdienstzeiten, miserend importers, ClaimRequest model, forward geocoding, heartbeat healthcheck. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
80 lines
2.5 KiB
TypeScript
80 lines
2.5 KiB
TypeScript
import { Pool } from 'pg';
|
|
import * as dotenv from 'dotenv';
|
|
import * as path from 'path';
|
|
|
|
// Load .env.local first (takes precedence), then .env
|
|
dotenv.config({ path: path.resolve(process.cwd(), '.env.local') });
|
|
dotenv.config({ path: path.resolve(process.cwd(), '.env') });
|
|
|
|
const pool = new Pool({
|
|
connectionString: process.env.DATABASE_URL,
|
|
});
|
|
|
|
async function checkEnrichmentDetail() {
|
|
try {
|
|
console.log('Connecting to database...\n');
|
|
|
|
// Check churches awaiting enrichment
|
|
const pendingResult = await pool.query(`
|
|
SELECT
|
|
country,
|
|
COUNT(*) as pending_count
|
|
FROM churches
|
|
WHERE google_place_id IS NULL
|
|
GROUP BY country
|
|
ORDER BY pending_count DESC
|
|
LIMIT 20;
|
|
`);
|
|
|
|
console.log('=== Churches Awaiting Enrichment (Top 20 Countries) ===');
|
|
let totalPending = 0;
|
|
pendingResult.rows.forEach((row) => {
|
|
console.log(`${row.country}: ${row.pending_count} churches`);
|
|
totalPending += parseInt(row.pending_count);
|
|
});
|
|
console.log(`\nTotal pending shown: ${totalPending}`);
|
|
|
|
// Check total stats
|
|
const statsResult = await pool.query(`
|
|
SELECT
|
|
COUNT(*) as total_churches,
|
|
COUNT(CASE WHEN google_place_id IS NOT NULL THEN 1 END) as enriched,
|
|
COUNT(CASE WHEN google_place_id IS NULL THEN 1 END) as pending
|
|
FROM churches;
|
|
`);
|
|
|
|
console.log('\n=== Overall Stats ===');
|
|
console.log(`Total churches: ${statsResult.rows[0].total_churches}`);
|
|
console.log(`Enriched: ${statsResult.rows[0].enriched} (${((statsResult.rows[0].enriched / statsResult.rows[0].total_churches) * 100).toFixed(2)}%)`);
|
|
console.log(`Pending: ${statsResult.rows[0].pending} (${((statsResult.rows[0].pending / statsResult.rows[0].total_churches) * 100).toFixed(2)}%)`);
|
|
|
|
// Check enrichment rate
|
|
const rateResult = await pool.query(`
|
|
SELECT
|
|
DATE(updated_at) as date,
|
|
COUNT(*) as enriched_count
|
|
FROM churches
|
|
WHERE google_place_id IS NOT NULL
|
|
AND updated_at > NOW() - INTERVAL '7 days'
|
|
GROUP BY DATE(updated_at)
|
|
ORDER BY date DESC;
|
|
`);
|
|
|
|
console.log('\n=== Enrichment Activity (Last 7 Days) ===');
|
|
if (rateResult.rows.length === 0) {
|
|
console.log('No enrichment activity in the last 7 days');
|
|
} else {
|
|
rateResult.rows.forEach((row) => {
|
|
console.log(`${row.date}: ${row.enriched_count} churches`);
|
|
});
|
|
}
|
|
|
|
} catch (error) {
|
|
console.error('Error checking enrichment detail:', error);
|
|
} finally {
|
|
await pool.end();
|
|
}
|
|
}
|
|
|
|
checkEnrichmentDetail();
|