diff --git a/spiffworkflow-backend/src/spiffworkflow_backend/routes/process_instances_controller.py b/spiffworkflow-backend/src/spiffworkflow_backend/routes/process_instances_controller.py index fbf33ad38..97d7f6323 100644 --- a/spiffworkflow-backend/src/spiffworkflow_backend/routes/process_instances_controller.py +++ b/spiffworkflow-backend/src/spiffworkflow_backend/routes/process_instances_controller.py @@ -11,7 +11,8 @@ from flask import jsonify from flask import make_response from flask import request from flask.wrappers import Response -from SpiffWorkflow.task import TaskState # type: ignore +from SpiffWorkflow.task import Task as SpiffTask # type: ignore +from SpiffWorkflow.task import TaskState from sqlalchemy import and_ from sqlalchemy import or_ @@ -536,6 +537,7 @@ def process_instance_task_list( process_instance: ProcessInstanceModel, all_tasks: bool = False, spiff_step: int = 0, + most_recent_tasks_only: bool = False, ) -> flask.wrappers.Response: """Process_instance_task_list.""" step_detail_query = db.session.query(SpiffStepDetailsModel).filter( @@ -611,7 +613,21 @@ def process_instance_task_list( ) tasks = [] - for spiff_task in spiff_tasks: + spiff_tasks_to_process = spiff_tasks + + if most_recent_tasks_only: + spiff_tasks_by_process_id_and_task_name: dict[str, SpiffTask] = {} + for spiff_task in spiff_tasks: + row_id = f"{spiff_task.task_spec._wf_spec.name}:{spiff_task.task_spec.name}" + if ( + row_id not in spiff_tasks_by_process_id_and_task_name + or spiff_task.last_state_change + > spiff_tasks_by_process_id_and_task_name[row_id].last_state_change + ): + spiff_tasks_by_process_id_and_task_name[row_id] = spiff_task + spiff_tasks_to_process = spiff_tasks_by_process_id_and_task_name.values() + + for spiff_task in spiff_tasks_to_process: task_spiff_step: Optional[int] = None if str(spiff_task.id) in steps_by_id: task_spiff_step = steps_by_id[str(spiff_task.id)].spiff_step diff --git a/spiffworkflow-backend/src/spiffworkflow_backend/routes/tasks_controller.py b/spiffworkflow-backend/src/spiffworkflow_backend/routes/tasks_controller.py index 325f32218..0afd721fd 100644 --- a/spiffworkflow-backend/src/spiffworkflow_backend/routes/tasks_controller.py +++ b/spiffworkflow-backend/src/spiffworkflow_backend/routes/tasks_controller.py @@ -532,14 +532,14 @@ def _get_tasks( human_tasks_query.add_columns( ProcessInstanceModel.process_model_identifier, ProcessInstanceModel.status.label("process_instance_status"), # type: ignore - ProcessInstanceModel.updated_at_in_seconds, - ProcessInstanceModel.created_at_in_seconds, UserModel.username.label("process_initiator_username"), # type: ignore GroupModel.identifier.label("assigned_user_group_identifier"), HumanTaskModel.task_name, HumanTaskModel.task_title, HumanTaskModel.process_model_display_name, HumanTaskModel.process_instance_id, + HumanTaskModel.updated_at_in_seconds, + HumanTaskModel.created_at_in_seconds, potential_owner_usernames_from_group_concat_or_similar, ) .order_by(desc(HumanTaskModel.id)) # type: ignore diff --git a/spiffworkflow-frontend/bin/cypress_pilot b/spiffworkflow-frontend/bin/cypress_pilot index 0d1e42eb3..102411ada 100755 --- a/spiffworkflow-frontend/bin/cypress_pilot +++ b/spiffworkflow-frontend/bin/cypress_pilot @@ -40,3 +40,4 @@ for attempt in $(seq 1 "$ATTEMPTS" ); do echo "${success},$(( end_time - start_time ))" >>"$cypress_run_file" done +echo "Recorded stats to ${cypress_run_file}" diff --git a/spiffworkflow-frontend/src/components/ProcessModelForm.tsx b/spiffworkflow-frontend/src/components/ProcessModelForm.tsx index 999356952..cd20c1170 100644 --- a/spiffworkflow-frontend/src/components/ProcessModelForm.tsx +++ b/spiffworkflow-frontend/src/components/ProcessModelForm.tsx @@ -306,7 +306,7 @@ export default function ProcessModelForm({ textInputs.push(