From a7745897483f5073787343c7389c412ea55ddaf0 Mon Sep 17 00:00:00 2001 From: jasquat <2487833+jasquat@users.noreply.github.com> Date: Thu, 7 Sep 2023 13:41:41 -0400 Subject: [PATCH] updated with tasks waiting for me query to include tasks manually assigned to the user w/ burnettk (#467) Co-authored-by: jasquat --- .../process_instance_report_service.py | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/spiffworkflow-backend/src/spiffworkflow_backend/services/process_instance_report_service.py b/spiffworkflow-backend/src/spiffworkflow_backend/services/process_instance_report_service.py index 94c32d0c..cd2640d6 100644 --- a/spiffworkflow-backend/src/spiffworkflow_backend/services/process_instance_report_service.py +++ b/spiffworkflow-backend/src/spiffworkflow_backend/services/process_instance_report_service.py @@ -553,13 +553,30 @@ class ProcessInstanceReportService: HumanTaskModel, and_( HumanTaskModel.process_instance_id == ProcessInstanceModel.id, - HumanTaskModel.lane_assignment_id.is_(None), # type: ignore HumanTaskModel.completed.is_(False), # type: ignore ), ).join( HumanTaskUserModel, and_(HumanTaskUserModel.human_task_id == HumanTaskModel.id, HumanTaskUserModel.user_id == user.id), ) + + user_group_assignment_for_lane_assignment = aliased(UserGroupAssignmentModel) + process_instance_query = process_instance_query.outerjoin( + user_group_assignment_for_lane_assignment, + and_( + user_group_assignment_for_lane_assignment.group_id == HumanTaskModel.lane_assignment_id, + user_group_assignment_for_lane_assignment.user_id == user.id, + ), + ).filter( + # it should show up in your "Waiting for me" list IF: + # 1) task is not assigned to a group OR + # 2) you are not in the group + # In the case of number 2, it probably means you were added to the task individually by an admin + or_( + HumanTaskModel.lane_assignment_id.is_(None), # type: ignore + user_group_assignment_for_lane_assignment.group_id.is_(None), + ) + ) human_task_already_joined = True restrict_human_tasks_to_user = user