mirror of
https://github.com/supabase/supabase.git
synced 2026-10-14 05:39:11 +03:00
fix: demo sql
This commit is contained in:
1 parent
cbb6f6c158
commit
3c91d3345c
2 files changed
+28
-2
No files matched your search
@@ -484,7 +484,9 @@ export function SurveyChart({
|
||||
</div>
|
||||
) : (
|
||||
<div className="px-8 pt-4 pb-8">
|
||||
{functionName ? (
|
||||
{generateSQLQuery ? (
|
||||
<CodeBlock lang="sql">{generateSQLQuery(activeFilters)}</CodeBlock>
|
||||
) : functionName ? (
|
||||
<CodeBlock lang="ts">
|
||||
{`// Function call: ${functionName}(${JSON.stringify(functionParams ? functionParams(activeFilters) : {}, null, 2)})`}
|
||||
</CodeBlock>
|
||||
|
||||
@@ -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<string, string>) {
|
||||
@@ -21,6 +21,29 @@ function buildFunctionParams(activeFilters: Record<string, string>) {
|
||||
return params
|
||||
}
|
||||
|
||||
function generateAcceleratorParticipationSQL(activeFilters: Record<string, string>) {
|
||||
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 (
|
||||
<SurveyChart
|
||||
@@ -29,6 +52,7 @@ export function AcceleratorParticipationChart() {
|
||||
filterColumns={['person_age', 'location', 'money_raised']}
|
||||
functionName="get_accelerator_stats"
|
||||
functionParams={buildFunctionParams}
|
||||
generateSQLQuery={generateAcceleratorParticipationSQL}
|
||||
/>
|
||||
)
|
||||
}
|
||||
Reference in new issue
Block a user