1414
1515@router .get ("" )
1616def summary (session : Session = Depends (get_session )) -> dict :
17- services = list (session .exec (select (Service )))
17+ services = list (session .exec (select (Service ). order_by ( Service . name ) ))
1818 dbs = list (session .exec (select (Database )))
1919 keys = list (session .exec (select (KeyRef )))
2020
21- running = 0
22- stopped = 0
23- error = 0
21+ running_services = []
22+ stopped_services = []
23+ error_services = []
2424 alerts : list [dict ] = []
2525
2626 for svc in services :
2727 refresh_status (session , svc )
28+ svc_data = {
29+ "id" : svc .id ,
30+ "name" : svc .name ,
31+ "port" : svc .port ,
32+ "status" : svc .status ,
33+ "has_start_command" : bool (svc .start_command ),
34+ }
35+
2836 if svc .status == "running" :
29- running += 1
37+ running_services . append ( svc_data )
3038 elif svc .status == "error" :
31- error += 1
39+ error_services . append ( svc_data )
3240 else :
33- stopped += 1
41+ stopped_services . append ( svc_data )
3442
3543 if svc .port is not None :
3644 in_use = is_port_in_use ("127.0.0.1" , int (svc .port ))
@@ -43,7 +51,7 @@ def summary(session: Session = Depends(get_session)) -> dict:
4351 }
4452 )
4553
46- if not svc .start_command :
54+ if not svc .start_command and ( svc . category or "" ). lower () not in { "repo" , "repos" } :
4755 alerts .append (
4856 {
4957 "type" : "missing_start_command" ,
@@ -52,23 +60,20 @@ def summary(session: Session = Depends(get_session)) -> dict:
5260 }
5361 )
5462
55- if svc .config_paths is not None and len (svc .config_paths ) == 0 :
56- # Not necessarily an error; keep low severity
57- pass
58-
5963 session .commit ()
6064
6165 ports_in_use = len ([s for s in services if s .port is not None ])
6266
6367 return {
64- "totals" : {
65- "services" : len (services ),
66- "running" : running ,
67- "stopped" : stopped ,
68- "error" : error ,
69- "databases" : len (dbs ),
70- "keys" : len (keys ),
71- "ports_reserved" : ports_in_use ,
72- },
68+ "services" : len (services ),
69+ "running" : len (running_services ),
70+ "stopped" : len (stopped_services ),
71+ "error" : len (error_services ),
72+ "databases" : len (dbs ),
73+ "keys" : len (keys ),
74+ "ports_reserved" : ports_in_use ,
75+ "running_services" : running_services ,
76+ "stopped_services" : stopped_services [:10 ],
77+ "error_services" : error_services ,
7378 "alerts" : alerts ,
7479 }
0 commit comments