From 3c91d3345cc4f2a52015b83d06d66ebea3fb6ee9 Mon Sep 17 00:00:00 2001 From: Danny White <3104761+dnywh@users.noreply.github.com> Date: Wed, 20 Aug 2025 16:18:11 +1000 Subject: [PATCH] fix: demo sql --- .../components/SurveyResults/SurveyChart.tsx | 4 ++- .../charts/AcceleratorParticipationChart.tsx | 26 ++++++++++++++++++- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/apps/www/components/SurveyResults/SurveyChart.tsx b/apps/www/components/SurveyResults/SurveyChart.tsx index aec3252b496..0aabeaffdfb 100644 --- a/apps/www/components/SurveyResults/SurveyChart.tsx +++ b/apps/www/components/SurveyResults/SurveyChart.tsx @@ -484,7 +484,9 @@ export function SurveyChart({ ) : (
- {functionName ? ( + {generateSQLQuery ? ( + {generateSQLQuery(activeFilters)} + ) : functionName ? ( {`// Function call: ${functionName}(${JSON.stringify(functionParams ? functionParams(activeFilters) : {}, null, 2)})`} diff --git a/apps/www/components/SurveyResults/charts/AcceleratorParticipationChart.tsx b/apps/www/components/SurveyResults/charts/AcceleratorParticipationChart.tsx index b05498f26cf..a3d77558565 100644 --- a/apps/www/components/SurveyResults/charts/AcceleratorParticipationChart.tsx +++ b/apps/www/components/SurveyResults/charts/AcceleratorParticipationChart.tsx @@ -1,4 +1,4 @@ -import { SurveyChart } from '../SurveyChart' +import { SurveyChart, buildWhereClause } from '../SurveyChart' // Helper function to convert filters to the format expected by the database function function buildFunctionParams(activeFilters: Record) { @@ -21,6 +21,29 @@ function buildFunctionParams(activeFilters: Record) { return params } +function generateAcceleratorParticipationSQL(activeFilters: Record) { + const whereClause = buildWhereClause(activeFilters, ['accelerator_participation IS NOT NULL']) + + return `WITH accelerator_mapping AS ( + SELECT + accelerator_participation, + CASE + WHEN accelerator_participation IN ('YC', 'Techstars', 'EF', '500 Global', 'Plug and Play', 'Antler') THEN accelerator_participation + WHEN accelerator_participation = 'Did not participate in an accelerator' THEN NULL + ELSE 'Other' + END AS accelerator_clean + FROM responses_2025 + ${whereClause ? '\n ' + whereClause : ''} +) +SELECT + accelerator_clean AS accelerator_participation, + COUNT(*) AS total +FROM accelerator_mapping +WHERE accelerator_clean IS NOT NULL +GROUP BY accelerator_clean +ORDER BY total DESC;` +} + export function AcceleratorParticipationChart() { return ( ) }