pyl w/ burnettk

This commit is contained in:
jasquat 2023-02-09 10:28:36 -05:00
parent bec263d24d
commit e9ee885efb
2 changed files with 27 additions and 17 deletions

View File

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

View File

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