Skip to content

Commit c9de24a

Browse files
bug fix listing
1 parent 5edcc8b commit c9de24a

File tree

2 files changed

+18
-15
lines changed

2 files changed

+18
-15
lines changed

services/director-v2/src/simcore_service_director_v2/api/rpc/_computations.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,8 @@ async def list_computations_latest_iteration_tasks_page(
129129
comp_tasks_repo = CompTasksRepository.instance(db_engine=app.state.engine)
130130
comp_runs_repo = CompRunsRepository.instance(db_engine=app.state.engine)
131131

132+
# Get latest
133+
132134
total, comp_tasks = await comp_tasks_repo.list_computational_tasks_rpc_domain(
133135
project_ids=project_ids,
134136
offset=offset,

services/director-v2/src/simcore_service_director_v2/modules/db/repositories/comp_runs.py

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -221,9 +221,7 @@ async def list_for_user__only_latest_iterations(
221221
if order_by is None:
222222
order_by = OrderBy(field=IDStr("run_id")) # default ordering
223223

224-
base_select_query = sa.select(
225-
*self._COMPUTATION_RUNS_RPC_GET_COLUMNS
226-
).select_from(
224+
_latest_runs = (
227225
sa.select(
228226
comp_runs.c.project_uuid,
229227
sa.func.max(comp_runs.c.iteration).label(
@@ -235,20 +233,23 @@ async def list_for_user__only_latest_iterations(
235233
& (
236234
comp_runs.c.metadata["product_name"].astext == product_name
237235
) # <-- NOTE: We might create a separate column for this for fast retrieval
238-
& (
239-
comp_runs.c.result.in_(
240-
[
241-
RUNNING_STATE_TO_DB[item]
242-
for item in RunningState.list_running_states()
243-
]
244-
)
245-
)
246-
if filter_only_running
247-
else True
248236
)
249237
.group_by(comp_runs.c.project_uuid)
250-
.subquery("latest_runs")
251-
.join(
238+
)
239+
if filter_only_running:
240+
_latest_runs = _latest_runs.where(
241+
comp_runs.c.result.in_(
242+
[
243+
RUNNING_STATE_TO_DB[item]
244+
for item in RunningState.list_running_states()
245+
]
246+
)
247+
)
248+
249+
base_select_query = sa.select(
250+
*self._COMPUTATION_RUNS_RPC_GET_COLUMNS
251+
).select_from(
252+
_latest_runs.subquery().join(
252253
comp_runs,
253254
sa.and_(
254255
comp_runs.c.project_uuid

0 commit comments

Comments
 (0)