4343 ServiceWithHistoryDBGet ,
4444)
4545from ..models .services_specifications import ServiceSpecificationsAtDB
46+ from . import _services_sql
4647from ._base import BaseRepository
4748from ._services_sql import (
4849 SERVICES_META_DATA_COLS ,
4950 AccessRightsClauses ,
50- _apply_services_filters ,
51- by_version ,
52- can_get_service_stmt ,
53- get_service_history_stmt ,
54- get_service_stmt ,
55- latest_services_total_count_stmt ,
56- list_latest_services_stmt ,
57- list_services_stmt ,
5851)
5952
6053_logger = logging .getLogger (__name__ )
@@ -101,7 +94,7 @@ async def list_services(
10194 return [
10295 ServiceMetaDataDBGet .model_validate (row )
10396 async for row in await conn .stream (
104- list_services_stmt (
97+ _services_sql . list_services_stmt (
10598 gids = gids ,
10699 execute_access = execute_access ,
107100 write_access = write_access ,
@@ -295,7 +288,7 @@ async def can_get_service(
295288 """Returns False if it cannot get the service i.e. not found or does not have access"""
296289 async with self .db_engine .begin () as conn :
297290 result = await conn .execute (
298- can_get_service_stmt (
291+ _services_sql . can_get_service_stmt (
299292 product_name = product_name ,
300293 user_id = user_id ,
301294 access_rights = AccessRightsClauses .can_read ,
@@ -316,7 +309,7 @@ async def can_update_service(
316309 ) -> bool :
317310 async with self .db_engine .begin () as conn :
318311 result = await conn .execute (
319- can_get_service_stmt (
312+ _services_sql . can_get_service_stmt (
320313 product_name = product_name ,
321314 user_id = user_id ,
322315 access_rights = AccessRightsClauses .can_edit ,
@@ -336,7 +329,7 @@ async def get_service_with_history(
336329 version : ServiceVersion ,
337330 ) -> ServiceWithHistoryDBGet | None :
338331
339- stmt_get = get_service_stmt (
332+ stmt_get = _services_sql . get_service_stmt (
340333 product_name = product_name ,
341334 user_id = user_id ,
342335 access_rights = AccessRightsClauses .can_read ,
@@ -349,7 +342,7 @@ async def get_service_with_history(
349342 row = result .one_or_none ()
350343
351344 if row :
352- stmt_history = get_service_history_stmt (
345+ stmt_history = _services_sql . get_service_history_stmt (
353346 product_name = product_name ,
354347 user_id = user_id ,
355348 access_rights = AccessRightsClauses .can_read ,
@@ -396,13 +389,13 @@ async def list_latest_services(
396389 ) -> tuple [PositiveInt , list [ServiceWithHistoryDBGet ]]:
397390
398391 # get page
399- stmt_total = latest_services_total_count_stmt (
392+ stmt_total = _services_sql . latest_services_total_count_stmt (
400393 product_name = product_name ,
401394 user_id = user_id ,
402395 access_rights = AccessRightsClauses .can_read ,
403396 filters = filters ,
404397 )
405- stmt_page = list_latest_services_stmt (
398+ stmt_page = _services_sql . list_latest_services_stmt (
406399 product_name = product_name ,
407400 user_id = user_id ,
408401 access_rights = AccessRightsClauses .can_read ,
@@ -459,7 +452,7 @@ async def get_service_history(
459452 """
460453 DEPRECATED: use get_service_history_page instead!
461454 """
462- stmt_history = get_service_history_stmt (
455+ stmt_history = _services_sql . get_service_history_stmt (
463456 product_name = product_name ,
464457 user_id = user_id ,
465458 access_rights = AccessRightsClauses .can_read ,
@@ -514,7 +507,7 @@ async def get_service_history_page(
514507 )
515508
516509 if filters :
517- base_stmt = _apply_services_filters (base_stmt , filters )
510+ base_stmt = _services_sql . apply_services_filters (base_stmt , filters )
518511
519512 base_subquery = base_stmt .subquery ()
520513
@@ -546,7 +539,7 @@ async def get_service_history_page(
546539 ),
547540 )
548541 )
549- .order_by (sql .desc (by_version (services_meta_data .c .version )))
542+ .order_by (sql .desc (_services_sql . by_version (services_meta_data .c .version )))
550543 .offset (offset )
551544 .limit (limit )
552545 )
0 commit comments