From 29a1bb5364866f4f95846196f9c3365925afc545 Mon Sep 17 00:00:00 2001 From: Jon Herron Date: Mon, 28 Nov 2022 11:15:40 -0500 Subject: [PATCH 1/2] Query fix with the gang --- .../routes/process_api_blueprint.py | 21 +++++++------------ 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/spiffworkflow-backend/src/spiffworkflow_backend/routes/process_api_blueprint.py b/spiffworkflow-backend/src/spiffworkflow_backend/routes/process_api_blueprint.py index 6f09df972..3fb0b66d7 100644 --- a/spiffworkflow-backend/src/spiffworkflow_backend/routes/process_api_blueprint.py +++ b/spiffworkflow-backend/src/spiffworkflow_backend/routes/process_api_blueprint.py @@ -899,7 +899,6 @@ def process_instance_list( SpiffStepDetailsModel.completed_by_user_id == g.user.id ) - # TODO: not sure if this is exactly what is wanted if report_filter.with_tasks_completed_by_my_group is True: process_instance_query = process_instance_query.filter( ProcessInstanceModel.status.in_(["complete", "error", "terminated"]) # type: ignore @@ -918,22 +917,18 @@ def process_instance_list( process_instance_query = process_instance_query.filter( SpiffLoggingModel.spiff_step == SpiffStepDetailsModel.spiff_step ) - - my_groups = ( - select(UserGroupAssignmentModel) # type: ignore - .where(UserGroupAssignmentModel.user_id == g.user.id) - .with_only_columns(UserGroupAssignmentModel.group_id) + process_instance_query = process_instance_query.join( + GroupModel, + GroupModel.id == SpiffStepDetailsModel.lane_assignment_id, ) - users_in_my_groups = ( - select(UserGroupAssignmentModel) # type: ignore - .where(UserGroupAssignmentModel.group_id.in_(my_groups)) - .with_only_columns(UserGroupAssignmentModel.user_id) + process_instance_query = process_instance_query.join( + UserGroupAssignmentModel, + UserGroupAssignmentModel.group_id == GroupModel.id, ) - process_instance_query = process_instance_query.filter( - SpiffStepDetailsModel.completed_by_user_id.in_(users_in_my_groups) # type: ignore + UserGroupAssignmentModel.user_id == g.user.id ) - + process_instances = ( process_instance_query.group_by(ProcessInstanceModel.id) .order_by( From e87b62c8969718b4ebc28511142db595abab9871 Mon Sep 17 00:00:00 2001 From: Jon Herron Date: Mon, 28 Nov 2022 11:17:41 -0500 Subject: [PATCH 2/2] Getting ./bin/pyl to pass --- .../src/spiffworkflow_backend/routes/process_api_blueprint.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/spiffworkflow-backend/src/spiffworkflow_backend/routes/process_api_blueprint.py b/spiffworkflow-backend/src/spiffworkflow_backend/routes/process_api_blueprint.py index 3fb0b66d7..739e689d2 100644 --- a/spiffworkflow-backend/src/spiffworkflow_backend/routes/process_api_blueprint.py +++ b/spiffworkflow-backend/src/spiffworkflow_backend/routes/process_api_blueprint.py @@ -30,7 +30,6 @@ from SpiffWorkflow.task import TaskState from sqlalchemy import and_ from sqlalchemy import asc from sqlalchemy import desc -from sqlalchemy import select from sqlalchemy.orm import joinedload from spiffworkflow_backend.exceptions.process_entity_not_found_error import ( @@ -928,7 +927,7 @@ def process_instance_list( process_instance_query = process_instance_query.filter( UserGroupAssignmentModel.user_id == g.user.id ) - + process_instances = ( process_instance_query.group_by(ProcessInstanceModel.id) .order_by(