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
@@ -724,6 +724,20 @@ Deno.serve(async (req) => {
|
||||
|
||||
if (saveError) throw new Error(`DB save failed: ${saveError.message}`);
|
||||
|
||||
// ─── Storage: save scrape_data.json to clinics/{domain}/{reportId}/ ───
|
||||
try {
|
||||
const domain = new URL(url).hostname.replace('www.', '');
|
||||
const jsonBytes = new TextEncoder().encode(JSON.stringify(scrapeDataFull, null, 2));
|
||||
await supabase.storage
|
||||
.from('clinic-data')
|
||||
.upload(`${domain}/${saved.id}/scrape_data.json`, jsonBytes, {
|
||||
contentType: 'application/json',
|
||||
upsert: true,
|
||||
});
|
||||
} catch (e) {
|
||||
console.warn('[storage] scrape_data.json upload failed:', e instanceof Error ? e.message : e);
|
||||
}
|
||||
|
||||
// ─── V3: clinics + analysis_runs (dual-write) ───
|
||||
let clinicId: string | null = null;
|
||||
let runId: string | null = null;
|
||||
|
||||
Reference in new issue
Block a user