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>
61 lines
1.9 KiB
TypeScript
61 lines
1.9 KiB
TypeScript
#!/usr/bin/env tsx
|
|
/**
|
|
* Export churches from NAS database to JSON
|
|
* Run this ON THE NAS (uses DATABASE_URL from .env)
|
|
*/
|
|
|
|
import { PrismaClient } from '@prisma/client';
|
|
import fs from 'fs/promises';
|
|
|
|
async function main() {
|
|
const country = process.argv[2] || 'PL';
|
|
|
|
console.log(`📦 Exporting ${country} data from database...`);
|
|
console.log(`DATABASE_URL: ${process.env.DATABASE_URL?.replace(/:[^:@]+@/, ':****@')}`);
|
|
|
|
const prisma = new PrismaClient();
|
|
|
|
try {
|
|
await prisma.$connect();
|
|
console.log('✅ Connected to database');
|
|
|
|
// Export churches with all schedules
|
|
const churches = await prisma.churches.findMany({
|
|
where: { country },
|
|
include: {
|
|
massSchedules: true,
|
|
confessionSchedules: true,
|
|
adorationSchedules: true,
|
|
}
|
|
});
|
|
|
|
console.log(`Found ${churches.length} churches in ${country}`);
|
|
|
|
// Count schedules
|
|
const massSchedules = churches.reduce((sum, c) => sum + (c.massSchedules?.length || 0), 0);
|
|
const confessionSchedules = churches.reduce((sum, c) => sum + (c.confessionSchedules?.length || 0), 0);
|
|
const adorationSchedules = churches.reduce((sum, c) => sum + (c.adorationSchedules?.length || 0), 0);
|
|
|
|
// Save to file
|
|
const exportFile = `export-${country}.json`;
|
|
await fs.writeFile(exportFile, JSON.stringify(churches, null, 2));
|
|
|
|
console.log(`\n✅ Exported to ${exportFile}`);
|
|
console.log(` - ${churches.length} churches`);
|
|
console.log(` - ${massSchedules} mass schedules`);
|
|
console.log(` - ${confessionSchedules} confession schedules`);
|
|
console.log(` - ${adorationSchedules} adoration schedules`);
|
|
console.log(`\nDownload with:`);
|
|
console.log(` scp albert@192.168.0.145:/volume1/docker/nearestmass/${exportFile} .`);
|
|
|
|
await prisma.$disconnect();
|
|
|
|
} catch (error) {
|
|
console.error('❌ Export failed:', error);
|
|
await prisma.$disconnect();
|
|
process.exit(1);
|
|
}
|
|
}
|
|
|
|
main().catch(console.error);
|