diff --git a/core/cli/helpers.py b/core/cli/helpers.py index 2a5681bb..84117ee7 100644 --- a/core/cli/helpers.py +++ b/core/cli/helpers.py @@ -585,12 +585,12 @@ async def load_convo( return convo -async def list_projects_old(db: SessionManager): +async def list_projects_branches_states(db: SessionManager): """ - List all projects in the database. + List all projects in the database, including their branches and project states """ sm = StateManager(db) - projects = await sm.list_projects_old() + projects = await sm.list_projects_with_branches_states() print(f"Available projects ({len(projects)}):") for project in projects: @@ -686,4 +686,11 @@ def init() -> tuple[UIBase, SessionManager, Namespace]: return (ui, db, args) -__all__ = ["parse_arguments", "load_config", "list_projects_json", "list_projects_old", "load_project", "init"] +__all__ = [ + "parse_arguments", + "load_config", + "list_projects_json", + "list_projects_branches_states", + "load_project", + "init", +] diff --git a/core/cli/main.py b/core/cli/main.py index d92b6e99..4a5cb5b3 100644 --- a/core/cli/main.py +++ b/core/cli/main.py @@ -17,8 +17,8 @@ from core.agents.orchestrator import Orchestrator from core.cli.helpers import ( delete_project, init, + list_projects_branches_states, list_projects_json, - list_projects_old, load_convo, load_project, print_convo, @@ -243,7 +243,7 @@ async def async_main( global telemetry_sent if args.list: - await list_projects_old(db) + await list_projects_branches_states(db) return True elif args.list_json: await list_projects_json(db) diff --git a/core/db/models/project.py b/core/db/models/project.py index 8974451d..7627b21d 100644 --- a/core/db/models/project.py +++ b/core/db/models/project.py @@ -88,7 +88,7 @@ class Project(Base): return result.fetchall() @staticmethod - async def get_all_projects_old(session: "AsyncSession") -> list["Project"]: + async def get_all_projects_with_branches_states(session: "AsyncSession") -> list["Project"]: """ Get all projects. diff --git a/core/state/state_manager.py b/core/state/state_manager.py index 5acb8ecb..5179ce5b 100644 --- a/core/state/state_manager.py +++ b/core/state/state_manager.py @@ -76,12 +76,12 @@ class StateManager: async with self.session_manager as session: return await Project.get_all_projects(session) - async def list_projects_old(self) -> list[Project]: + async def list_projects_with_branches_states(self) -> list[Project]: """ :return: List of projects with branches and states (old) - for debugging """ async with self.session_manager as session: - return await Project.get_all_projects_old(session) + return await Project.get_all_projects_with_branches_states(session) async def get_project_states(self, project_id: Optional[UUID], branch_id: Optional[UUID]) -> list[ProjectState]: return await ProjectState.get_project_states(self.current_session, project_id, branch_id) diff --git a/tests/cli/test_cli.py b/tests/cli/test_cli.py index 3732be76..ad23de67 100644 --- a/tests/cli/test_cli.py +++ b/tests/cli/test_cli.py @@ -7,8 +7,8 @@ import pytest from core.cli.helpers import ( init, + list_projects_branches_states, list_projects_json, - list_projects_old, load_config, load_project, parse_arguments, @@ -213,11 +213,11 @@ async def test_list_projects(mock_StateManager, capsys): ) project.name = "project1" - sm.list_projects_old = AsyncMock(return_value=[project]) - await list_projects_old(None) + sm.list_projects_with_branches_states = AsyncMock(return_value=[project]) + await list_projects_branches_states(None) mock_StateManager.assert_called_once_with(None) - sm.list_projects_old.assert_awaited_once_with() + sm.list_projects_with_branches_states.assert_awaited_once_with() data = capsys.readouterr().out