From 195744ba98185b5b74cc0647d2cfc42b9e67b366 Mon Sep 17 00:00:00 2001 From: Anthony Alaribe Date: Wed, 7 Jan 2026 23:37:57 +0100 Subject: [PATCH 1/2] Fix SQL syntax error when casting aggregations with aliases The chart query was generating invalid SQL like `(count(*) AS count_)::float` because the float cast wrapped the entire expression including the alias. Fixed by adding ::float cast directly in Count/CountIf/DCount Display instances, so the alias is correctly placed after the cast: `count(*)::float AS count_` --- src/Pkg/Parser.hs | 4 ++-- src/Pkg/Parser/Stats.hs | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Pkg/Parser.hs b/src/Pkg/Parser.hs index f74b35a59..8ff035899 100644 --- a/src/Pkg/Parser.hs +++ b/src/Pkg/Parser.hs @@ -253,11 +253,11 @@ sqlFromQueryComponents sqlCfg qc = if null qc.groupByClause then "'" <> (if null qc.select then "count" else "value") <> "'" else "COALESCE(" <> fromMaybe "status_code" (listToMaybe qc.groupByClause) <> "::text, 'null')" - aggCol = if null qc.select then "count(*)" else fromMaybe "count(*)" (listToMaybe qc.select) + aggCol = if null qc.select then "count(*)::float" else fromMaybe "count(*)::float" (listToMaybe qc.select) timeBucketExpr = "time_bucket('" <> binInterval <> "', " <> timestampCol <> ")" firstGroupCol = fromMaybe "status_code" (listToMaybe qc.groupByClause) groupByPart = if null qc.groupByClause then timeBucketExpr else timeBucketExpr <> ", " <> firstGroupCol - in [fmt|SELECT extract(epoch from {timeBucketExpr})::integer, {groupCol}, ({aggCol})::float + in [fmt|SELECT extract(epoch from {timeBucketExpr})::integer, {groupCol}, {aggCol} FROM {fromTable} WHERE {buildWhere} GROUP BY {groupByPart} ORDER BY {timeBucketExpr} DESC {limitClause}|] Nothing -> diff --git a/src/Pkg/Parser/Stats.hs b/src/Pkg/Parser/Stats.hs index 6eab24ed9..56616ed9f 100644 --- a/src/Pkg/Parser/Stats.hs +++ b/src/Pkg/Parser/Stats.hs @@ -403,12 +403,12 @@ withAlias sql explicitAlias agg = sql <> " AS " <> fromMaybe (defaultAlias agg) instance Display AggFunction where - displayPrec _prec agg@(Count sub alias) = displayBuilder $ withAlias ("count(" <> display sub <> ")") alias agg - displayPrec _prec agg@(CountIf cond alias) = displayBuilder $ withAlias ("COUNT(*) FILTER (WHERE " <> display cond <> ")") alias agg + displayPrec _prec agg@(Count sub alias) = displayBuilder $ withAlias ("count(" <> display sub <> ")::float") alias agg + displayPrec _prec agg@(CountIf cond alias) = displayBuilder $ withAlias ("COUNT(*) FILTER (WHERE " <> display cond <> ")::float") alias agg -- dcount(field [, accuracy]) -> COUNT(DISTINCT field) -- Note: KQL accuracy parameter (0-4 for HyperLogLog precision) is intentionally ignored -- because PostgreSQL's COUNT(DISTINCT) doesn't support HLL accuracy hints - displayPrec _prec agg@(DCount sub _ alias) = displayBuilder $ withAlias ("COUNT(DISTINCT " <> display sub <> ")") alias agg + displayPrec _prec agg@(DCount sub _ alias) = displayBuilder $ withAlias ("COUNT(DISTINCT " <> display sub <> ")::float") alias agg displayPrec _prec agg@(P50 sub alias) = displayBuilder $ withAlias ("approx_percentile(0.50, percentile_agg((" <> display sub <> ")::float))::int") alias agg displayPrec _prec agg@(P75 sub alias) = displayBuilder $ withAlias ("approx_percentile(0.75, percentile_agg((" <> display sub <> ")::float))::int") alias agg displayPrec _prec agg@(P90 sub alias) = displayBuilder $ withAlias ("approx_percentile(0.90, percentile_agg((" <> display sub <> ")::float))::int") alias agg From 2b9fc97683827d21915acda2d82df0ed9d7ff4f2 Mon Sep 17 00:00:00 2001 From: Anthony Alaribe Date: Thu, 8 Jan 2026 00:46:24 +0100 Subject: [PATCH 2/2] Fix drawer causing white page background Override --page-scroll-bg-on to use --color-bgBase so the drawer toggle doesn't override the page background with DaisyUI's default. --- static/public/assets/css/tailwind.css | 1 + 1 file changed, 1 insertion(+) diff --git a/static/public/assets/css/tailwind.css b/static/public/assets/css/tailwind.css index 2fa0fc107..1b5bc7ba3 100644 --- a/static/public/assets/css/tailwind.css +++ b/static/public/assets/css/tailwind.css @@ -239,6 +239,7 @@ [data-theme] { --backgroundPrimary: rgb(255 255 255); --rounded-btn: 0.5rem; + --page-scroll-bg-on: var(--color-bgBase); --tw-prose-body: var(--color-textStrong) !important; }