added some code get only the most recent tasks for a process and task, get updated times from human tasks instead of the process instance, and show the current value for the notification type w/ burnettk

This commit is contained in:
jasquat 2023-03-07 17:13:46 -05:00
parent 9b15390f40
commit 3862e79ad7
No known key found for this signature in database
4 changed files with 22 additions and 5 deletions

View File

@ -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 = []
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

View File

@ -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

View File

@ -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}"

View File

@ -306,7 +306,7 @@ export default function ProcessModelForm({
textInputs.push(
<Select
id="notification-type"
defaultValue="fault"
defaultValue={processModel.fault_or_suspend_on_exception}
labelText="Notification Type"
onChange={(event: any) => {
onNotificationTypeChanged(event.target.value);