feat: per-URL clinic folder — auto-save all scraped data to Storage
Each analysis run now creates a dedicated folder in Supabase Storage:
clinics/{domain}/{reportId}/
├── scrape_data.json (discover-channels: website scrape + Perplexity)
├── channel_data.json (collect-channel-data: all channel API results)
└── report.json (generate-report: final AI-generated report)
Screenshots also moved from {reportId}/{id}.png to:
clinics/{domain}/{reportId}/screenshots/{id}.png
Migration: 20260407_clinic_data_storage.sql creates 'clinic-data' bucket
(private, 10MB/file, JSON only). All writes are non-fatal — pipeline
continues even if Storage upload fails.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
1 parent
ae87953fa0
commit
2cda26a649
5 files changed
+103
-3
No files matched your search
@@ -358,6 +358,21 @@ ${JSON.stringify(scrapeData.branding || {}, null, 2).slice(0, 1000)}
|
||||
} catch (e) { console.error("V3 clinic update error:", e); }
|
||||
}
|
||||
|
||||
// ─── Storage: save report.json to clinics/{domain}/{reportId}/ ───
|
||||
try {
|
||||
const domain = new URL(row.url || "").hostname.replace('www.', '');
|
||||
const jsonBytes = new TextEncoder().encode(JSON.stringify(report, null, 2));
|
||||
await supabase.storage
|
||||
.from('clinic-data')
|
||||
.upload(`clinics/${domain}/${body.reportId}/report.json`, jsonBytes, {
|
||||
contentType: 'application/json',
|
||||
upsert: true,
|
||||
});
|
||||
console.log(`[storage] report.json → clinics/${domain}/${body.reportId}/`);
|
||||
} catch (e) {
|
||||
console.warn('[storage] report.json upload failed:', e instanceof Error ? e.message : e);
|
||||
}
|
||||
|
||||
return new Response(
|
||||
JSON.stringify({
|
||||
success: true,
|
||||
|
||||
Reference in new issue
Block a user