Skip to content

Commit 6fde859

Browse files
committed
simplify query
1 parent d481905 commit 6fde859

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
@@ -251,8 +251,7 @@ WITH
251251

252252
SELECT
253253
t.template_ids,
254-
array_agg(DISTINCT ai.user_id)::uuid[] AS active_user_ids,
255-
''::text AS access_method, -- TODO(mafredri): Remove.
254+
COUNT(DISTINCT ai.user_id) AS active_users,
256255
ai.app_name AS slug_or_port,
257256
ai.display_name,
258257
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)