Skip to content

Commit 91dce4f

Browse files
committed
fix coalesce and cleanup with array remove
1 parent 0db240a commit 91dce4f

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

coderd/database/queries.sql.go

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

coderd/database/queries/insights.sql

+2-2
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ WITH ts AS (
6565
SELECT
6666
COALESCE((SELECT ids FROM template_ids), '{}')::uuid[] AS template_ids,
6767
-- Return IDs so we can combine this with GetTemplateAppInsights.
68-
array_agg(DISTINCT user_id)::uuid[] AS active_user_ids,
68+
COALESCE(array_agg(DISTINCT user_id), '{}')::uuid[] AS active_user_ids,
6969
COALESCE(SUM(usage_vscode_seconds), 0)::bigint AS usage_vscode_seconds,
7070
COALESCE(SUM(usage_jetbrains_seconds), 0)::bigint AS usage_jetbrains_seconds,
7171
COALESCE(SUM(usage_reconnecting_pty_seconds), 0)::bigint AS usage_reconnecting_pty_seconds,
@@ -194,7 +194,7 @@ WITH ts AS (
194194
SELECT
195195
from_ AS start_time,
196196
to_ AS end_time,
197-
COALESCE(array_agg(DISTINCT template_id) FILTER (WHERE template_id IS NOT NULL), '{}')::uuid[] AS template_ids,
197+
array_remove(array_agg(DISTINCT template_id), NULL)::uuid[] AS template_ids,
198198
COUNT(DISTINCT user_id) AS active_users
199199
FROM unflattened_usage_by_day
200200
GROUP BY from_, to_;

0 commit comments

Comments
 (0)