mirror of
https://github.com/status-im/spiff-arena.git
synced 2025-03-01 01:40:42 +00:00
only return the tasks for the given bpmn process omitting tasks for call activities (#1562)
Co-authored-by: jasquat <jasquat@users.noreply.github.com>
This commit is contained in:
parent
c23cf38c33
commit
afd598bb8f
@ -377,14 +377,16 @@ def _process_instance_task_list(
|
||||
This is how we know what the state of each task is and how to color things.
|
||||
"""
|
||||
bpmn_process_ids = []
|
||||
bpmn_process = None
|
||||
if bpmn_process_guid:
|
||||
bpmn_process = BpmnProcessModel.query.filter_by(guid=bpmn_process_guid).first()
|
||||
else:
|
||||
bpmn_process = process_instance.bpmn_process
|
||||
|
||||
if bpmn_process is None:
|
||||
raise ApiError(
|
||||
error_code="bpmn_process_not_found",
|
||||
message=(
|
||||
f"Cannot find a bpmn process with guid '{bpmn_process_guid}' for process instance '{process_instance.id}'"
|
||||
),
|
||||
message=(f"Cannot find a bpmn process with guid '{bpmn_process_guid}' for process instance '{process_instance.id}'"),
|
||||
status_code=400,
|
||||
)
|
||||
|
||||
|
@ -10,6 +10,7 @@ from SpiffWorkflow.bpmn.workflow import BpmnWorkflow # type: ignore
|
||||
from SpiffWorkflow.exceptions import WorkflowException # type: ignore
|
||||
from SpiffWorkflow.task import Task as SpiffTask # type: ignore
|
||||
from SpiffWorkflow.util.task import TaskState # type: ignore
|
||||
from sqlalchemy import and_
|
||||
from sqlalchemy import asc
|
||||
|
||||
from spiffworkflow_backend.exceptions.error import TaskMismatchError
|
||||
@ -565,6 +566,17 @@ class TaskService:
|
||||
direct_children = BpmnProcessModel.query.filter(
|
||||
BpmnProcessModel.direct_parent_process_id.in_(bpmn_process_ids) # type: ignore
|
||||
).all()
|
||||
direct_children = (
|
||||
BpmnProcessModel.query.join(TaskModel, TaskModel.guid == BpmnProcessModel.guid)
|
||||
.join(TaskDefinitionModel, TaskDefinitionModel.id == TaskModel.task_definition_id)
|
||||
.filter(
|
||||
and_(
|
||||
TaskDefinitionModel.typename == "SubWorkflowTask",
|
||||
TaskModel.bpmn_process_id.in_(bpmn_process_ids), # type: ignore
|
||||
)
|
||||
)
|
||||
.all()
|
||||
)
|
||||
if len(direct_children) > 0:
|
||||
return bpmn_processes + cls.bpmn_process_and_descendants(direct_children)
|
||||
return bpmn_processes
|
||||
|
Loading…
x
Reference in New Issue
Block a user