i think it works

This commit is contained in:
Joe Fleming
2026-03-07 17:04:48 -07:00
parent c3c8683f53
commit f3bb38aea1
2 changed files with 52 additions and 10 deletions

View File

@@ -201,6 +201,15 @@ class Database:
result.append((proj.name or proj.worktree, ws_names, has_workspaces))
return sorted(result)
def get_session_counts_by_project(self) -> dict:
"""Return a dict of project_id -> active session count."""
assert self.conn is not None
cursor = self.conn.cursor()
cursor.execute(
"SELECT project_id, COUNT(*) FROM session WHERE time_archived IS NULL GROUP BY project_id"
)
return {row[0]: row[1] for row in cursor.fetchall()}
def get_session(self, session_id: str) -> Optional[Session]:
"""Get a single session by ID."""
sessions = self.get_sessions(include_archived=True)