diff --git a/frontend/src/components/uploader/report-config/BigqueryBasedReportConfig.tsx b/frontend/src/components/uploader/report-config/BigqueryBasedReportConfig.tsx index 8aa1acb..4c07da0 100644 --- a/frontend/src/components/uploader/report-config/BigqueryBasedReportConfig.tsx +++ b/frontend/src/components/uploader/report-config/BigqueryBasedReportConfig.tsx @@ -52,6 +52,7 @@ export default function BigqueryBasedReportConfig({ schema }: Props) { schema={schema} dataSourceType="bigquery" rowCountByColumn={rowCountByColumn} + prefill={() => {}} onSubmit={onSubmit} /> ); diff --git a/frontend/src/components/uploader/report-config/CSVBasedReportConfig.tsx b/frontend/src/components/uploader/report-config/CSVBasedReportConfig.tsx index ebe7850..70c0ada 100644 --- a/frontend/src/components/uploader/report-config/CSVBasedReportConfig.tsx +++ b/frontend/src/components/uploader/report-config/CSVBasedReportConfig.tsx @@ -11,7 +11,7 @@ import { } from "../../../types/report-config"; import ReportConfig from "./ReportConfig"; -const sampleDataPrefills: PrefillConfig = { +const commercePrefills: PrefillConfig = { metricColumn: { aggregationOption: "nunique", singularMetric: { @@ -39,6 +39,87 @@ const sampleDataPrefills: PrefillConfig = { }, }; +const doorDashPrefills: PrefillConfig = { + metricColumn: { + aggregationOption: "ratio", + ratioMetric: { + metricName: "cancelation_rate", + numerator: { + aggregationMethod: "nunique", + columnName: "order_id", + filter: { + column: "order_status", + value: "canceled", + } + }, + denominator: { + aggregationMethod: "nunique", + columnName: "order_id", + }, + }, + }, + dateColumn: 'order_date', + groupByColumns: [ + "order_canceled_by", + "age_group", + "has_dash_pass", + "city", + "state", + "gender", + "merchant", + "store", + "vertical", + "tip_percentage", + "channel", + "hour_of_the_day", + "promo_code", + "payment_method" + ], + baseDateRange: { + from: createNewDateWithBrowserTimeZone("2023-08-14"), + to: createNewDateWithBrowserTimeZone("2023-08-20"), + }, + comparisonDateRange: { + from: createNewDateWithBrowserTimeZone("2023-08-21"), + to: createNewDateWithBrowserTimeZone("2023-08-27"), + }, +} + +const insurancePrefills: PrefillConfig = { + metricColumn: { + aggregationOption: "sum", + singularMetric: { + columnName: "total_claim_amount", + } + }, + groupByColumns: [ + "age_group", + "insured_gender", + "insured_education_level", + "insured_occupation", + "insured_hobbies", + "insured_relationship", + "auto_make", + "auto_year", + "incident_type", + "incident_severity", + "incident_state", + "incident_city", + "property_damage", + "police_report_available", + "authorities_contacted" + ], + dateColumn: 'incident_date', + baseDateRange: { + from: createNewDateWithBrowserTimeZone("2023-07-04"), + to: createNewDateWithBrowserTimeZone("2023-07-31"), + }, + comparisonDateRange: { + from: createNewDateWithBrowserTimeZone("2023-08-01"), + to: createNewDateWithBrowserTimeZone("2023-08-28"), + }, +} + interface Props { schema: CSVSchema; prefillWithSampleData: boolean; @@ -56,6 +137,21 @@ export default function CSVBasedReportConfig({ const [rowCountByColumn, setRowCountByColumn] = useState<{ [key: string]: number; }>({}); + const [prefillConfig, setPrefillConfig] = useState(undefined); + + const prefill = (sample: "doordash" | "insurance") => { + if (sample === "doordash") { + setPrefillConfig(doorDashPrefills); + } else if (sample === "insurance") { + setPrefillConfig(insurancePrefills); + } + } + + useEffect(() => { + if (prefillWithSampleData) { + setPrefillConfig(commercePrefills); + } + }, [prefillWithSampleData]); useEffect(() => { async function calculateCountByDateAndColumn() { @@ -118,7 +214,8 @@ export default function CSVBasedReportConfig({ dataSourceType="csv" rowCountByColumn={rowCountByColumn} rowCountByDateColumn={rowCountByDateAndColumn} - prefilledConfigs={prefillWithSampleData ? sampleDataPrefills : undefined} + prefilledConfigs={prefillConfig} + prefill={prefill} onSubmit={onSubmit} /> ); diff --git a/frontend/src/components/uploader/report-config/ReportConfig.tsx b/frontend/src/components/uploader/report-config/ReportConfig.tsx index 40b4fc3..f274f0f 100644 --- a/frontend/src/components/uploader/report-config/ReportConfig.tsx +++ b/frontend/src/components/uploader/report-config/ReportConfig.tsx @@ -11,6 +11,7 @@ import { Title, } from "@tremor/react"; import { useEffect, useState } from "react"; +import { getServerData } from "../../../common/server-data/server-data-loader"; import { useTracking } from "../../../common/tracking"; import { DataSourceType, Schema } from "../../../types/data-source"; import { @@ -33,6 +34,7 @@ type Props = { rowCountByColumn: RowCountByColumn; rowCountByDateColumn?: RowCountByDateAndColumn; prefilledConfigs?: PrefillConfig; + prefill: (sample: "doordash" | "insurance") => void; onSubmit: ( dateColumn: string, dateColumnType: string, @@ -51,6 +53,7 @@ function ReportConfig({ rowCountByColumn, rowCountByDateColumn, prefilledConfigs, + prefill, onSubmit, }: Props) { const { trackEvent } = useTracking(); @@ -60,6 +63,7 @@ function ReportConfig({ const [groupByColumns, setGroupByColumns] = useState([]); const [metricColumn, setMetricColumn] = useState(); const [expectedValue, setExpectedValue] = useState(); + const debugMode = getServerData().settings.showDebugInfo; const [comparisonDateRangeData, setComparisonDateRangeData] = useState({ @@ -222,6 +226,24 @@ function ReportConfig({ return ( Report Config + { + debugMode && ( + + + + + + )} +