From 48c5a7225353f23b65bec22b875fa61ff4045cba Mon Sep 17 00:00:00 2001 From: hrsong99 Date: Wed, 3 Dec 2025 14:31:10 +0900 Subject: [PATCH] fix(chart): update aggregation functions to use toFloat64OrNull and simplify where conditions --- packages/db/src/services/chart.service.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/packages/db/src/services/chart.service.ts b/packages/db/src/services/chart.service.ts index 38c7813e0..d0b42a93a 100644 --- a/packages/db/src/services/chart.service.ts +++ b/packages/db/src/services/chart.service.ts @@ -173,23 +173,23 @@ export function getChartSql({ } if (event.segment === 'property_sum' && event.property) { - sb.select.count = `sum(toFloat64(${getSelectPropertyKey(event.property)})) as count`; - sb.where.property = `${getSelectPropertyKey(event.property)} IS NOT NULL AND notEmpty(${getSelectPropertyKey(event.property)})`; + sb.select.count = `sum(toFloat64OrNull(${getSelectPropertyKey(event.property)})) as count`; + sb.where.property = `${getSelectPropertyKey(event.property)} IS NOT NULL`; } if (event.segment === 'property_average' && event.property) { - sb.select.count = `avg(toFloat64(${getSelectPropertyKey(event.property)})) as count`; - sb.where.property = `${getSelectPropertyKey(event.property)} IS NOT NULL AND notEmpty(${getSelectPropertyKey(event.property)})`; + sb.select.count = `avg(toFloat64OrNull(${getSelectPropertyKey(event.property)})) as count`; + sb.where.property = `${getSelectPropertyKey(event.property)} IS NOT NULL`; } if (event.segment === 'property_max' && event.property) { - sb.select.count = `max(toFloat64(${getSelectPropertyKey(event.property)})) as count`; - sb.where.property = `${getSelectPropertyKey(event.property)} IS NOT NULL AND notEmpty(${getSelectPropertyKey(event.property)})`; + sb.select.count = `max(toFloat64OrNull(${getSelectPropertyKey(event.property)})) as count`; + sb.where.property = `${getSelectPropertyKey(event.property)} IS NOT NULL`; } if (event.segment === 'property_min' && event.property) { - sb.select.count = `min(toFloat64(${getSelectPropertyKey(event.property)})) as count`; - sb.where.property = `${getSelectPropertyKey(event.property)} IS NOT NULL AND notEmpty(${getSelectPropertyKey(event.property)})`; + sb.select.count = `min(toFloat64OrNull(${getSelectPropertyKey(event.property)})) as count`; + sb.where.property = `${getSelectPropertyKey(event.property)} IS NOT NULL`; } if (event.segment === 'one_event_per_user') {