From 7556b5adc015b32b52bbcb2d493d5f7d5dbc7f86 Mon Sep 17 00:00:00 2001 From: Juan Antonio Osorio Date: Fri, 17 Jan 2025 13:50:15 +0200 Subject: [PATCH] Re-add missing functions from workspace CRUD https://github.com/stacklok/codegate/pull/633 accidentally deleted some functions that were introduced by https://github.com/stacklok/codegate/pull/620 This re-introduces them. Signed-off-by: Juan Antonio Osorio --- src/codegate/workspaces/crud.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/codegate/workspaces/crud.py b/src/codegate/workspaces/crud.py index 9902e80b..9d2beef6 100644 --- a/src/codegate/workspaces/crud.py +++ b/src/codegate/workspaces/crud.py @@ -1,8 +1,8 @@ import datetime -from typing import Optional, Tuple +from typing import Optional, Tuple, List from codegate.db.connection import DbReader, DbRecorder -from codegate.db.models import Session, Workspace +from codegate.db.models import Session, Workspace, WorkspaceActive, ActiveWorkspace class WorkspaceCrud: @@ -21,12 +21,18 @@ async def add_workspace(self, new_workspace_name: str) -> bool: workspace_created = await db_recorder.add_workspace(new_workspace_name) return bool(workspace_created) - async def get_workspaces(self): + async def get_workspaces(self)-> List[WorkspaceActive]: """ Get all workspaces """ return await self._db_reader.get_workspaces() + async def get_active_workspace(self) -> Optional[ActiveWorkspace]: + """ + Get the active workspace + """ + return await self._db_reader.get_active_workspace() + async def _is_workspace_active_or_not_exist( self, workspace_name: str ) -> Tuple[bool, Optional[Session], Optional[Workspace]]: