demo_report_save_week
Save a week's classified demo report to Supabase, including summary and per-lead data, without duplicates. Re-running same week converges and returns warnings if pipeline USD does not reconcile.
Instructions
Persist one week's classified demo report to Supabase (idempotent).
Upserts the week-summary row on week_ending and replaces that week's lead
rows. Re-running a week converges — never duplicates. Returns a non-fatal
warnings list if pipeline_usd does not reconcile with counted-inbound
lead amounts (the week is still saved).
Args: week_summary_json: JSON object for one demo_report_weeks row. Required key: week_ending (YYYY-MM-DD, the Sunday). Other keys: week_start, total_inbound, unbranded, branded, direct, events, outbound_revivals, paid, flagged, ambiguous, ai_surface_leads, pipeline_usd, warnings, complete. leads_json: JSON array of per-lead rows. Each: deal_id, company, domain, classification, icp_fit, amount, dealstage, found_us, ai_surface_origin, hubspot_current_source, hubspot_update_to, rationale. week_ending is attached automatically.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| leads_json | Yes | ||
| week_summary_json | Yes |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |