Skip to content

Commit 8195c9a

Browse files
committed
simplify query
1 parent 424298e commit 8195c9a

File tree

3 files changed

+10
-17
lines changed

3 files changed

+10
-17
lines changed

coderd/database/queries.sql.go

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

coderd/database/queries/insights.sql

+1-2
Original file line numberDiff line numberDiff line change
@@ -262,8 +262,7 @@ WITH
262262

263263
SELECT
264264
t.template_ids,
265-
array_agg(DISTINCT ai.user_id)::uuid[] AS active_user_ids,
266-
''::text AS access_method, -- TODO(mafredri): Remove.
265+
COUNT(DISTINCT ai.user_id) AS active_users,
267266
ai.app_name AS slug_or_port,
268267
ai.display_name,
269268
ai.icon,

coderd/insights.go

-3
Original file line numberDiff line numberDiff line change
@@ -468,9 +468,6 @@ func convertTemplateInsightsApps(usage database.GetTemplateInsightsRow, appUsage
468468
//
469469
// ORDER BY access_method, slug_or_port, display_name, icon, is_app
470470
slices.SortFunc(appUsage, func(a, b database.GetTemplateAppInsightsRow) int {
471-
if a.AccessMethod != b.AccessMethod {
472-
return strings.Compare(a.AccessMethod, b.AccessMethod)
473-
}
474471
if a.SlugOrPort != b.SlugOrPort {
475472
return strings.Compare(a.SlugOrPort, b.SlugOrPort)
476473
}

0 commit comments

Comments
 (0)