zrhoffman commented on a change in pull request #5144:
URL: https://github.com/apache/trafficcontrol/pull/5144#discussion_r504839135
##########
File path: traffic_ops/traffic_ops_golang/topology/topologies.go
##########
@@ -563,6 +614,23 @@ JOIN topology_cachegroup tc on t.name = tc.topology
return query
}
+func selectEmptyCacheGroupsQuery() string {
+ // language=SQL
+ query := `
+ SELECT c."name", COUNT((
+ SELECT s2.id FROM server s2
+ JOIN "type" t ON s."type" = t.id
+ WHERE s2.id = s.id
+ )) server_count
+ FROM cachegroup c
+ LEFT JOIN "server" s ON c.id = s.cachegroup
+ WHERE c."name" = ANY(CAST(:cachegroup_names AS TEXT[]))
+ GROUP BY c."name"
+ ORDER BY server_count
Review comment:
Due to the `LEFT JOIN` making `COUNT(*)` include `NULL`s, it would need
to be something like `COUNT(*) FILTER (WHERE s.id IS NOT NULL)`.
Simplified in 118863a5e
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]