feat: Add stale process monitor, users route, landing page, archive old scripts
- Add backend stale process monitoring API (/api/stale-processes) - Add users management route - Add frontend landing page and stale process monitor UI on /scraper-tools - Move old development scripts to backend/archive/ - Update frontend build with new features 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
72
backend/archive/sync-by-address.ts
Normal file
72
backend/archive/sync-by-address.ts
Normal file
@@ -0,0 +1,72 @@
|
||||
import { Pool } from 'pg';
|
||||
|
||||
async function syncByAddress() {
|
||||
const sailPool = new Pool({
|
||||
connectionString: 'postgresql://sail:password@localhost:5432/dutchie_menus'
|
||||
});
|
||||
|
||||
const dutchiePool = new Pool({
|
||||
connectionString: 'postgresql://dutchie:dutchie_local_pass@localhost:54320/dutchie_menus'
|
||||
});
|
||||
|
||||
try {
|
||||
console.log('🔄 Syncing enriched data from sail → dutchie (by address)\\n');
|
||||
|
||||
// Get all enriched dispensaries from sail
|
||||
const result = await sailPool.query(`
|
||||
SELECT name, address, city, state, zip, dba_name, website, phone,
|
||||
google_rating, google_review_count
|
||||
FROM azdhs_list
|
||||
WHERE dba_name IS NOT NULL
|
||||
`);
|
||||
|
||||
console.log(`📋 Found ${result.rows.length} enriched records in sail DB\\n`);
|
||||
|
||||
let matched = 0;
|
||||
let notFound = 0;
|
||||
|
||||
for (const disp of result.rows) {
|
||||
// Try to find matching record in dutchie DB by address + city
|
||||
const updateResult = await dutchiePool.query(`
|
||||
UPDATE azdhs_list
|
||||
SET
|
||||
dba_name = $1,
|
||||
website = $2,
|
||||
phone = $3,
|
||||
google_rating = $4,
|
||||
google_review_count = $5,
|
||||
updated_at = CURRENT_TIMESTAMP
|
||||
WHERE address = $6 AND city = $7
|
||||
RETURNING id, name
|
||||
`, [
|
||||
disp.dba_name,
|
||||
disp.website,
|
||||
disp.phone,
|
||||
disp.google_rating,
|
||||
disp.google_review_count,
|
||||
disp.address,
|
||||
disp.city
|
||||
]);
|
||||
|
||||
if (updateResult.rowCount > 0) {
|
||||
matched++;
|
||||
if (matched % 20 === 0) {
|
||||
console.log(` ✅ Matched ${matched}/${result.rows.length}...`);
|
||||
}
|
||||
} else {
|
||||
notFound++;
|
||||
console.log(` ⚠️ No match: ${disp.name} at ${disp.address}, ${disp.city}`);
|
||||
}
|
||||
}
|
||||
|
||||
console.log(`\\n📊 Results:`);
|
||||
console.log(` ✅ Matched and synced: ${matched}`);
|
||||
console.log(` ⚠️ Not found in dutchie DB: ${notFound}`);
|
||||
|
||||
} finally {
|
||||
await sailPool.end();
|
||||
await dutchiePool.end();
|
||||
}
|
||||
}
|
||||
|
||||
syncByAddress().catch(console.error);
|
||||
Reference in New Issue
Block a user