@@ -90,22 +90,16 @@ async def list_trashed_projects(
9090 return cast (int , total_count ), folders
9191
9292
93- async def patch_project (
93+ async def get_project (
9494 app : web .Application ,
9595 connection : AsyncConnection | None = None ,
9696 * ,
9797 project_uuid : ProjectID ,
98- new_partial_project_data : dict ,
9998) -> ProjectDBGet :
100-
101- async with transaction_context (get_asyncpg_engine (app ), connection ) as conn :
102- result = await conn .stream (
103- projects .update ()
104- .values (last_change_date = sql .func .now (), ** new_partial_project_data )
105- .where (projects .c .uuid == f"{ project_uuid } " )
106- .returning (* PROJECT_DB_COLS )
107- )
108- row = await result .first ()
99+ async with pass_or_acquire_connection (get_asyncpg_engine (app ), connection ) as conn :
100+ query = sql .select (PROJECT_DB_COLS ).where (projects .c .uuid == f"{ project_uuid } " )
101+ result = await conn .execute (query )
102+ row = result .one_or_none ()
109103 if row is None :
110104 raise ProjectNotFoundError (project_uuid = project_uuid )
111105 return ProjectDBGet .model_validate (row )
@@ -170,3 +164,43 @@ async def batch_get_trashed_by_primary_gid(
170164 rows = {row .uuid : row .trashed_by_primary_gid async for row in result }
171165
172166 return [rows .get (uuid ) for uuid in projects_uuids_str ]
167+
168+
169+ async def patch_project (
170+ app : web .Application ,
171+ connection : AsyncConnection | None = None ,
172+ * ,
173+ project_uuid : ProjectID ,
174+ new_partial_project_data : dict ,
175+ ) -> None :
176+
177+ async with transaction_context (get_asyncpg_engine (app ), connection ) as conn :
178+ result = await conn .stream (
179+ projects .update ()
180+ .values (
181+ ** new_partial_project_data ,
182+ last_change_date = sql .func .now (),
183+ )
184+ .where (projects .c .uuid == f"{ project_uuid } " )
185+ )
186+ row = await result .one_or_none ()
187+ if row is None :
188+ raise ProjectNotFoundError (project_uuid = project_uuid )
189+
190+
191+ async def delete_project (
192+ app : web .Application ,
193+ connection : AsyncConnection | None = None ,
194+ * ,
195+ project_uuid : ProjectID ,
196+ ) -> ProjectDBGet :
197+ async with transaction_context (get_asyncpg_engine (app ), connection ) as conn :
198+ result = await conn .stream (
199+ projects .delete ()
200+ .where (projects .c .uuid == f"{ project_uuid } " )
201+ .returning (* PROJECT_DB_COLS )
202+ )
203+ row = await result .one_or_none ()
204+ if row is None :
205+ raise ProjectNotFoundError (project_uuid = project_uuid )
206+ return ProjectDBGet .model_validate (row )
0 commit comments