diff --git a/VERSION b/VERSION index be14282..7d85683 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.5.3 +0.5.4 diff --git a/internal/httpapi/impl.go b/internal/httpapi/impl.go index b07fcb1..0074011 100644 --- a/internal/httpapi/impl.go +++ b/internal/httpapi/impl.go @@ -304,10 +304,24 @@ func (s *Server) GetGraph(ctx context.Context, req gen.GetGraphRequestObject) (g LEFT JOIN entity_status st ON st.entity_id = e.id ORDER BY e.slug`, rootID, depth, req.Params.RelType) } else { + // Whole-graph view: pick the most-connected entities first so the + // graph shows actual topology, not just whatever sorts first + // alphabetically. Without this the cap fills with exec:* rows and + // drops every host/lxc/service/vm — and every edge those entities + // connect — because edges require both endpoints in the node set. nodes, err = s.queryEntities(ctx, ` - SELECT `+entityCols+` FROM entities e + SELECT `+entityCols+` + FROM entities e LEFT JOIN entity_status st ON st.entity_id = e.id - ORDER BY e.slug LIMIT $1`, + WHERE e.id IN ( + SELECT e2.id FROM entities e2 + LEFT JOIN relationships r ON r.valid_to IS NULL + AND (r.source_id = e2.id OR r.target_id = e2.id) + GROUP BY e2.id + ORDER BY count(r.type) DESC, e2.slug + LIMIT $1 + ) + ORDER BY e.slug`, graphNodeCap+1) if err == nil && len(nodes) > graphNodeCap { nodes = nodes[:graphNodeCap]