File tree Expand file tree Collapse file tree 2 files changed +28
-1
lines changed
services/web/server/src/simcore_service_webserver/projects Expand file tree Collapse file tree 2 files changed +28
-1
lines changed Original file line number Diff line number Diff line change 88from common_library .exclude import Unset , is_set
99from models_library .basic_types import IDStr
1010from models_library .groups import GroupID
11- from models_library .projects import ProjectID
11+ from models_library .projects import Project , ProjectID
1212from models_library .rest_ordering import OrderBy , OrderDirection
1313from models_library .rest_pagination import MAXIMUM_NUMBER_OF_ITEMS_PER_PAGE
1414from models_library .workspaces import WorkspaceID
@@ -151,6 +151,24 @@ async def batch_get_project_name(
151151 return [rows .get (project_uuid ) for project_uuid in projects_uuids_str ]
152152
153153
154+ async def batch_get_projects (
155+ app : web .Application ,
156+ connection : AsyncConnection | None = None ,
157+ * ,
158+ project_uuids : list [ProjectID ],
159+ ) -> list [Project ]:
160+ if not project_uuids :
161+ return []
162+ async with pass_or_acquire_connection (get_asyncpg_engine (app ), connection ) as conn :
163+ query = (
164+ sql .select (projects )
165+ .select_from (projects )
166+ .where (projects .c .uuid .in_ ([f"{ uuid } " for uuid in project_uuids ]))
167+ )
168+ result = await conn .stream (query )
169+ return [Project .model_validate (row ) async for row in result ]
170+
171+
154172def _select_trashed_by_primary_gid_query () -> sql .Select :
155173 return sql .select (
156174 projects .c .uuid ,
Original file line number Diff line number Diff line change @@ -275,6 +275,15 @@ async def batch_get_project_name(
275275 return [name if name else "Unknown" for name in get_project_names ]
276276
277277
278+ async def batch_get_projects (
279+ app : web .Application , project_uuids : list [ProjectID ]
280+ ) -> list [Project ]:
281+ return await _projects_repository .batch_get_projects (
282+ app = app ,
283+ project_uuids = project_uuids ,
284+ )
285+
286+
278287#
279288# UPDATE project -----------------------------------------------------
280289#
You can’t perform that action at this time.
0 commit comments