From f437aea897566a488e4f017fd80bd2c7430c5eb0 Mon Sep 17 00:00:00 2001 From: Nate Kelley Date: Wed, 5 Feb 2025 08:12:13 -0700 Subject: [PATCH 1/2] use colors in tooltip cache --- .../hooks/useOptions/useOptions.tsx | 3 ++- .../useTooltipOptions.tsx | 21 +++++++++++++++---- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/web/src/components/charts/BusterChartJS/hooks/useOptions/useOptions.tsx b/web/src/components/charts/BusterChartJS/hooks/useOptions/useOptions.tsx index b4fd61bba..d308e04f3 100644 --- a/web/src/components/charts/BusterChartJS/hooks/useOptions/useOptions.tsx +++ b/web/src/components/charts/BusterChartJS/hooks/useOptions/useOptions.tsx @@ -169,7 +169,8 @@ export const useOptions = ({ columnSettings, datasetOptions, hasMismatchedTooltipsAndMeasures, - disableTooltip + disableTooltip, + colors }); const options: ChartProps['options'] = useMemo(() => { diff --git a/web/src/components/charts/BusterChartJS/hooks/useOptions/useTooltipOptions.ts/useTooltipOptions.tsx b/web/src/components/charts/BusterChartJS/hooks/useOptions/useTooltipOptions.ts/useTooltipOptions.tsx index db28e34eb..9fca43920 100644 --- a/web/src/components/charts/BusterChartJS/hooks/useOptions/useTooltipOptions.ts/useTooltipOptions.tsx +++ b/web/src/components/charts/BusterChartJS/hooks/useOptions/useTooltipOptions.ts/useTooltipOptions.tsx @@ -32,6 +32,7 @@ interface UseTooltipOptionsProps { datasetOptions: DatasetOption[]; hasMismatchedTooltipsAndMeasures: boolean; disableTooltip: boolean; + colors: string[]; } export const useTooltipOptions = ({ @@ -44,7 +45,8 @@ export const useTooltipOptions = ({ columnSettings, selectedAxis, datasetOptions, - disableTooltip + disableTooltip, + colors }: UseTooltipOptionsProps): DeepPartial => { const tooltipCache = useRef>({}); @@ -53,6 +55,10 @@ export const useTooltipOptions = ({ [columnLabelFormats] ); + const colorsStringCache = useMemo(() => { + return colors.map((c) => String(c)).join(''); + }, [colors]); + const mode: TooltipOptions['mode'] = useMemo(() => { if (selectedChartType === 'scatter') { return 'nearest'; @@ -107,7 +113,12 @@ export const useTooltipOptions = ({ }, [useGlobalPercentage, selectedChartType, columnSettings, tooltipKeys]); const memoizedExternal = useMemoizedFn((context: TooltipContext) => { - const key = createTooltipCacheKey(context.chart, keyToUsePercentage, columnLabelFormatsString); + const key = createTooltipCacheKey( + context.chart, + keyToUsePercentage, + columnLabelFormatsString, + colorsStringCache + ); const matchedCacheItem = tooltipCache.current[key]; const result = externalTooltip( context, @@ -149,7 +160,8 @@ export const useTooltipOptions = ({ const createTooltipCacheKey = ( chart: ChartJSOrUndefined, keyToUsePercentage: string[], - columnLabelFormatsString: string + columnLabelFormatsString: string, + colorsStringCache: string ) => { if (!chart?.tooltip) return ''; @@ -159,7 +171,8 @@ const createTooltipCacheKey = ( chart.tooltip.title.join(''), chart.tooltip.body?.map((b) => b.lines.join('')).join(''), keyToUsePercentage.join(''), - columnLabelFormatsString + columnLabelFormatsString, + colorsStringCache ]; return parts.join(''); From 2be738365652428b59bb59d24f68845bfd8fa132 Mon Sep 17 00:00:00 2001 From: dal Date: Wed, 5 Feb 2025 11:36:31 -0700 Subject: [PATCH 2/2] you learn something new every day... a schema in pg can't start with a number. --- api/src/utils/stored_values/mod.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/api/src/utils/stored_values/mod.rs b/api/src/utils/stored_values/mod.rs index da2044e76..3bdbc2d57 100644 --- a/api/src/utils/stored_values/mod.rs +++ b/api/src/utils/stored_values/mod.rs @@ -41,12 +41,12 @@ pub async fn ensure_stored_values_schema(organization_id: &Uuid) -> Result<()> { // Create schema and table using raw SQL let schema_name = organization_id.to_string().replace("-", "_"); let create_schema_sql = format!( - "CREATE SCHEMA IF NOT EXISTS {}_values", + "CREATE SCHEMA IF NOT EXISTS values_{}", schema_name ); let create_table_sql = format!( - "CREATE TABLE IF NOT EXISTS {}_values.values_v1 ( + "CREATE TABLE IF NOT EXISTS values_{}.values_v1 ( value text NOT NULL, dataset_id uuid NOT NULL, column_name text NOT NULL, @@ -60,7 +60,7 @@ pub async fn ensure_stored_values_schema(organization_id: &Uuid) -> Result<()> { let create_index_sql = format!( "CREATE INDEX IF NOT EXISTS values_v1_embedding_idx - ON {}_values.values_v1 + ON values_{}.values_v1 USING ivfflat (embedding vector_cosine_ops)", schema_name );