Feature/no data for finished spiff tasks (#661)

* do not add data to spiff tasks if that task is finished w/ burnettk

* build docker image for this branch w/ burnettk

---------

Co-authored-by: jasquat <jasquat@users.noreply.github.com>
This commit is contained in:
jasquat 2023-11-14 15:47:20 -05:00 committed by GitHub
parent 12c8b899f0
commit 1d37001727
4 changed files with 16 additions and 8 deletions

View File

@ -32,7 +32,7 @@ on:
branches: branches:
- main - main
- spiffdemo - spiffdemo
- feature/drop-id-column-on-json-data - feature/no-data-for-finished-spiff-tasks
jobs: jobs:
create_frontend_docker_image: create_frontend_docker_image:

View File

@ -647,8 +647,10 @@ class ProcessInstanceProcessor:
bpmn_subprocess_id_to_guid_mappings: dict | None = None, bpmn_subprocess_id_to_guid_mappings: dict | None = None,
) -> None: ) -> None:
json_data_hashes = set() json_data_hashes = set()
states_to_not_rehydrate_data = ["COMPLETED", "CANCELLED", "ERROR"]
for task in tasks: for task in tasks:
json_data_hashes.add(task.json_data_hash) if task.state not in states_to_not_rehydrate_data:
json_data_hashes.add(task.json_data_hash)
json_data_records = JsonDataModel.query.filter(JsonDataModel.hash.in_(json_data_hashes)).all() # type: ignore json_data_records = JsonDataModel.query.filter(JsonDataModel.hash.in_(json_data_hashes)).all() # type: ignore
json_data_mappings = {} json_data_mappings = {}
for json_data_record in json_data_records: for json_data_record in json_data_records:
@ -659,7 +661,10 @@ class ProcessInstanceProcessor:
bpmn_subprocess_guid = bpmn_subprocess_id_to_guid_mappings[task.bpmn_process_id] bpmn_subprocess_guid = bpmn_subprocess_id_to_guid_mappings[task.bpmn_process_id]
tasks_dict = spiff_bpmn_process_dict["subprocesses"][bpmn_subprocess_guid]["tasks"] tasks_dict = spiff_bpmn_process_dict["subprocesses"][bpmn_subprocess_guid]["tasks"]
tasks_dict[task.guid] = task.properties_json tasks_dict[task.guid] = task.properties_json
tasks_dict[task.guid]["data"] = json_data_mappings[task.json_data_hash] task_data = {}
if task.state not in states_to_not_rehydrate_data:
task_data = json_data_mappings[task.json_data_hash]
tasks_dict[task.guid]["data"] = task_data
@classmethod @classmethod
def _get_full_bpmn_process_dict( def _get_full_bpmn_process_dict(

View File

@ -9,7 +9,6 @@ from typing import Any
import pytest import pytest
from flask.app import Flask from flask.app import Flask
from flask.testing import FlaskClient from flask.testing import FlaskClient
from SpiffWorkflow.util.task import TaskState # type: ignore
from spiffworkflow_backend.exceptions.process_entity_not_found_error import ProcessEntityNotFoundError from spiffworkflow_backend.exceptions.process_entity_not_found_error import ProcessEntityNotFoundError
from spiffworkflow_backend.models.db import db from spiffworkflow_backend.models.db import db
from spiffworkflow_backend.models.process_group import ProcessGroup from spiffworkflow_backend.models.process_group import ProcessGroup
@ -2117,8 +2116,10 @@ class TestProcessApi(BaseTest):
processor = ProcessInstanceProcessor(process_instance) processor = ProcessInstanceProcessor(process_instance)
spiff_task = processor.get_task_by_bpmn_identifier("script_task_two", processor.bpmn_process_instance) spiff_task = processor.get_task_by_bpmn_identifier("script_task_two", processor.bpmn_process_instance)
assert spiff_task is not None assert spiff_task is not None
assert spiff_task.state == TaskState.ERROR task_model = TaskModel.query.filter_by(guid=str(spiff_task.id)).first()
assert spiff_task.data == {"my_var": "THE VAR"} assert task_model is not None
assert task_model.state == "ERROR"
assert task_model.get_data() == {"my_var": "THE VAR"}
def test_process_model_file_create( def test_process_model_file_create(
self, self,

View File

@ -876,8 +876,10 @@ class TestProcessInstanceProcessor(BaseTest):
"script_task_two", processor_final.bpmn_process_instance "script_task_two", processor_final.bpmn_process_instance
) )
assert spiff_task is not None assert spiff_task is not None
assert spiff_task.state == TaskState.ERROR task_model = TaskModel.query.filter_by(guid=str(spiff_task.id)).first()
assert spiff_task.data == {"my_var": "THE VAR"} assert task_model is not None
assert task_model.state == "ERROR"
assert task_model.get_data() == {"my_var": "THE VAR"}
process_instance_events = process_instance.process_instance_events process_instance_events = process_instance.process_instance_events
assert len(process_instance_events) == 4 assert len(process_instance_events) == 4