From 5bf50944c748ba82c4b3c624a6faf2a0ce5841eb Mon Sep 17 00:00:00 2001 From: jasquat Date: Mon, 6 Mar 2023 17:24:01 -0500 Subject: [PATCH] avoid calling task_definition and bpmn_process_definition more than we need to w/ burnettk --- .../services/process_instance_processor.py | 22 +++++++++++++------ 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/spiffworkflow-backend/src/spiffworkflow_backend/services/process_instance_processor.py b/spiffworkflow-backend/src/spiffworkflow_backend/services/process_instance_processor.py index e73e7ff0..e48597bf 100644 --- a/spiffworkflow-backend/src/spiffworkflow_backend/services/process_instance_processor.py +++ b/spiffworkflow-backend/src/spiffworkflow_backend/services/process_instance_processor.py @@ -561,16 +561,24 @@ class ProcessInstanceProcessor: .filter_by(bpmn_process_definition_parent_id=bpmn_process_definition.id) .all() ) + + bpmn_subprocess_definition_bpmn_identifiers = {} for bpmn_subprocess_definition in bpmn_process_subprocess_definitions: - spec = cls._get_definition_dict_for_bpmn_process_definition( - bpmn_subprocess_definition - ) + bpmn_process_definition_dict: dict = bpmn_subprocess_definition.properties_json spiff_bpmn_process_dict["subprocess_specs"][ bpmn_subprocess_definition.bpmn_identifier - ] = spec - cls._set_definition_dict_for_bpmn_subprocess_definitions( - bpmn_subprocess_definition, spiff_bpmn_process_dict - ) + ] = bpmn_process_definition_dict + spiff_bpmn_process_dict["subprocess_specs"][ + bpmn_subprocess_definition.bpmn_identifier + ]['task_specs'] = {} + bpmn_subprocess_definition_bpmn_identifiers[bpmn_subprocess_definition.id] = bpmn_subprocess_definition.bpmn_identifier + + task_definitions = TaskDefinitionModel.query.filter( + TaskDefinitionModel.bpmn_process_definition_id.in_(bpmn_subprocess_definition_bpmn_identifiers.keys()) # type: ignore + ).all() + for task_definition in task_definitions: + bpmn_subprocess_definition_bpmn_identifier = bpmn_subprocess_definition_bpmn_identifiers[task_definition.bpmn_process_definition_id] + spiff_bpmn_process_dict["subprocess_specs"][bpmn_subprocess_definition_bpmn_identifier]['task_specs'][task_definition.bpmn_identifier] = task_definition.properties_json @classmethod def _get_bpmn_process_dict(cls, bpmn_process: BpmnProcessModel) -> dict: