File tree Expand file tree Collapse file tree 5 files changed +25
-15
lines changed
packages/postgres-database/src/simcore_postgres_database/migration/versions
resource-usage-tracker/src/simcore_service_resource_usage_tracker/services/modules/db
web/server/src/simcore_service_webserver/licenses Expand file tree Collapse file tree 5 files changed +25
-15
lines changed Original file line number Diff line number Diff line change 11"""rename usages to checkouts
22
33Revision ID: aa6da21a0055
4- Revises: 77ac824a77ff
4+ Revises: 52a0e8148dd5
55Create Date: 2024-12-17 13:47:09.304574+00:00
66
77"""
1111
1212# revision identifiers, used by Alembic.
1313revision = "aa6da21a0055"
14- down_revision = "77ac824a77ff "
14+ down_revision = "52a0e8148dd5 "
1515branch_labels = None
1616depends_on = None
1717
Original file line number Diff line number Diff line change @@ -114,6 +114,8 @@ async def list_(
114114
115115 async with pass_or_acquire_connection (engine , connection ) as conn :
116116 total_count = await conn .scalar (count_query )
117+ if total_count is None :
118+ total_count = 0
117119
118120 result = await conn .stream (list_query )
119121 items : list [LicensedItemCheckoutDB ] = [
@@ -208,8 +210,7 @@ async def get_currently_used_seats_for_item_and_wallet(
208210 )
209211
210212 async with pass_or_acquire_connection (engine , connection ) as conn :
211- result = await conn .execute (sum_stmt )
212- row = result .first ()
213- if row is None or row [0 ] is None :
213+ total_sum = await conn .scalar (sum_stmt )
214+ if total_sum is None :
214215 return 0
215- return int ( row [ 0 ] )
216+ return cast ( int , total_sum )
Original file line number Diff line number Diff line change @@ -116,6 +116,8 @@ async def list_(
116116
117117 async with pass_or_acquire_connection (engine , connection ) as conn :
118118 total_count = await conn .scalar (count_query )
119+ if total_count is None :
120+ total_count = 0
119121
120122 result = await conn .stream (list_query )
121123 items : list [LicensedItemsPurchasesDB ] = [
@@ -181,8 +183,7 @@ async def get_active_purchased_seats_for_item_and_wallet(
181183 )
182184
183185 async with pass_or_acquire_connection (engine , connection ) as conn :
184- result = await conn .execute (sum_stmt )
185- row = result .first ()
186- if row is None or row [0 ] is None :
186+ total_sum = await conn .scalar (sum_stmt )
187+ if total_sum is None :
187188 return 0
188- return int ( row [ 0 ] )
189+ return cast ( int , total_sum )
Original file line number Diff line number Diff line change @@ -376,7 +376,9 @@ async def get_osparc_credits_aggregated_by_service(
376376
377377 subquery = base_query .subquery ()
378378 count_query = sa .select (sa .func .count ()).select_from (subquery )
379- count_result = await conn .execute (count_query )
379+ count_result = await conn .scalar (count_query )
380+ if count_result is None :
381+ count_result = 0
380382
381383 # Default ordering and pagination
382384 list_query = (
@@ -387,7 +389,7 @@ async def get_osparc_credits_aggregated_by_service(
387389 list_result = await conn .execute (list_query )
388390
389391 return (
390- cast (int , count_result . scalar () ),
392+ cast (int , count_result ),
391393 [
392394 OsparcCreditsAggregatedByServiceKeyDB .model_validate (row )
393395 for row in list_result .fetchall ()
Original file line number Diff line number Diff line change 2424
2525async def checkout_licensed_item_for_wallet (
2626 app : web .Application ,
27- licensed_item_id : LicensedItemID ,
28- wallet_id : WalletID ,
27+ * ,
28+ # access context
2929 product_name : ProductName ,
30+ wallet_id : WalletID ,
31+ user_id : UserID ,
32+ # checkout args
33+ licensed_item_id : LicensedItemID ,
3034 num_of_seats : int ,
3135 service_run_id : ServiceRunId ,
32- user_id : UserID ,
3336) -> webserver_licensed_items_checkouts .LicensedItemCheckoutGet :
3437 # Check whether user has access to the wallet
3538 await get_wallet_by_user (
@@ -69,8 +72,11 @@ async def checkout_licensed_item_for_wallet(
6972
7073async def release_licensed_item_for_wallet (
7174 app : web .Application ,
75+ * ,
76+ # access context
7277 product_name : ProductName ,
7378 user_id : UserID ,
79+ # release args
7480 licensed_item_checkout_id : LicensedItemCheckoutID ,
7581) -> webserver_licensed_items_checkouts .LicensedItemCheckoutGet :
7682 rpc_client = get_rabbitmq_rpc_client (app )
You can’t perform that action at this time.
0 commit comments