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 0ca0ada1..7c23f250 100644 --- a/spiffworkflow-backend/src/spiffworkflow_backend/routes/process_instances_controller.py +++ b/spiffworkflow-backend/src/spiffworkflow_backend/routes/process_instances_controller.py @@ -556,29 +556,28 @@ def process_instance_task_list( get_task_data: bool = False, ) -> flask.wrappers.Response: """Process_instance_task_list.""" - step_detail_query = ( - db.session.query(SpiffStepDetailsModel) - .filter( - SpiffStepDetailsModel.process_instance_id == process_instance.id, - ) + step_detail_query = db.session.query(SpiffStepDetailsModel).filter( + SpiffStepDetailsModel.process_instance_id == process_instance.id, ) if spiff_step > 0: - step_detail_query = step_detail_query.filter(SpiffStepDetailsModel.spiff_step <= spiff_step) + step_detail_query = step_detail_query.filter( + SpiffStepDetailsModel.spiff_step <= spiff_step + ) step_details = step_detail_query.all() - bpmn_json = json.loads(process_instance.bpmn_json) - tasks = bpmn_json['tasks'] + bpmn_json = json.loads(process_instance.bpmn_json or "{}") + tasks = bpmn_json["tasks"] # if step_detail is not None and process_instance.bpmn_json is not None: for step_detail in step_details: - print(f"step_detail.task_id: {step_detail.task_id}") - print(f"step_detail.bpmn_task_identifier: {step_detail.bpmn_task_identifier}") if step_detail.task_id in tasks: - task_data = step_detail.task_json['task_data'] | step_detail.task_json['python_env'] + task_data = ( + step_detail.task_json["task_data"] | step_detail.task_json["python_env"] + ) if task_data is None: task_data = {} - tasks[step_detail.task_id]['data'] = task_data + tasks[step_detail.task_id]["data"] = task_data process_instance.bpmn_json = json.dumps(bpmn_json) 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 d011c978..dc75ac6a 100644 --- a/spiffworkflow-backend/src/spiffworkflow_backend/services/process_instance_processor.py +++ b/spiffworkflow-backend/src/spiffworkflow_backend/services/process_instance_processor.py @@ -682,7 +682,12 @@ class ProcessInstanceProcessor: "lane_assignment_id": lane_assignment_id, } - def spiff_step_details_mapping(self, spiff_task: Optional[SpiffTask]=None, start_in_seconds: Optional[float] = 0, end_in_seconds: Optional[float] = 0) -> dict: + def spiff_step_details_mapping( + self, + spiff_task: Optional[SpiffTask] = None, + start_in_seconds: Optional[float] = 0, + end_in_seconds: Optional[float] = 0, + ) -> dict: """SaveSpiffStepDetails.""" # bpmn_json = self.serialize() # wf_json = json.loads(bpmn_json) @@ -696,8 +701,10 @@ class ProcessInstanceProcessor: return {} task_data = default_registry.convert(spiff_task.data) - python_env = default_registry.convert(self._script_engine.environment.last_result()) - + python_env = default_registry.convert( + self._script_engine.environment.last_result() + ) + task_json: Dict[str, Any] = { # "tasks": wf_json["tasks"], # "subprocesses": wf_json["subprocesses"], @@ -1528,13 +1535,17 @@ class ProcessInstanceProcessor: def will_complete_task(task: SpiffTask) -> None: if should_log(task): - current_task_start_in_seconds['time'] = time.time() + current_task_start_in_seconds["time"] = time.time() self.increment_spiff_step() def did_complete_task(task: SpiffTask) -> None: if should_log(task): self._script_engine.environment.revise_state_with_task_data(task) - step_details.append(self.spiff_step_details_mapping(task, current_task_start_in_seconds['time'], time.time())) + step_details.append( + self.spiff_step_details_mapping( + task, current_task_start_in_seconds["time"], time.time() + ) + ) try: self.bpmn_process_instance.refresh_waiting_tasks()