fixed tests
This commit is contained in:
parent
3782864dc9
commit
6a8676281c
|
@ -67,6 +67,7 @@ class ProcessInstanceModel(SpiffworkflowBaseDBModel):
|
|||
bpmn_process_id: int | None = db.Column(ForeignKey(BpmnProcessModel.id), nullable=True) # type: ignore
|
||||
bpmn_process = relationship(BpmnProcessModel, cascade="delete")
|
||||
tasks = relationship("TaskModel", cascade="delete") # type: ignore
|
||||
process_instance_events = relationship("ProcessInstanceEventModel", cascade="delete") # type: ignore
|
||||
|
||||
spiff_serializer_version = db.Column(db.String(50), nullable=True)
|
||||
|
||||
|
|
|
@ -1818,7 +1818,10 @@ class ProcessInstanceProcessor:
|
|||
db.session.add(json_data)
|
||||
|
||||
self.add_event_to_process_instance(
|
||||
self.process_instance_model, ProcessInstanceEventType.task_completed.value, task_guid=task_model.guid
|
||||
self.process_instance_model,
|
||||
ProcessInstanceEventType.task_completed.value,
|
||||
task_guid=task_model.guid,
|
||||
user_id=user.id,
|
||||
)
|
||||
|
||||
# this is the thing that actually commits the db transaction (on behalf of the other updates above as well)
|
||||
|
@ -1970,10 +1973,13 @@ class ProcessInstanceProcessor:
|
|||
|
||||
@classmethod
|
||||
def add_event_to_process_instance(
|
||||
cls, process_instance: ProcessInstanceModel, event_type: str, task_guid: Optional[str] = None
|
||||
cls,
|
||||
process_instance: ProcessInstanceModel,
|
||||
event_type: str,
|
||||
task_guid: Optional[str] = None,
|
||||
user_id: Optional[int] = None,
|
||||
) -> None:
|
||||
user_id = None
|
||||
if g.user:
|
||||
if user_id is None and hasattr(g, "user") and g.user:
|
||||
user_id = g.user.id
|
||||
process_instance_event = ProcessInstanceEventModel(
|
||||
process_instance_id=process_instance.id, event_type=event_type, timestamp=time.time(), user_id=user_id
|
||||
|
|
|
@ -18,6 +18,7 @@ from spiffworkflow_backend.models.message_instance_correlation import (
|
|||
)
|
||||
from spiffworkflow_backend.models.process_instance import ProcessInstanceModel
|
||||
from spiffworkflow_backend.models.process_instance_event import ProcessInstanceEventModel
|
||||
from spiffworkflow_backend.models.process_instance_event import ProcessInstanceEventType
|
||||
from spiffworkflow_backend.models.spiff_step_details import SpiffStepDetailsModel
|
||||
from spiffworkflow_backend.models.task import TaskModel # noqa: F401
|
||||
from spiffworkflow_backend.services.assertion_service import safe_assertion
|
||||
|
@ -146,9 +147,9 @@ class TaskModelSavingDelegate(EngineStepDelegate):
|
|||
self._update_json_data_dicts_using_list(json_data_dict_list)
|
||||
|
||||
if task_model.state == "COMPLETED" or task_failed:
|
||||
event_type = "task_completed"
|
||||
event_type = ProcessInstanceEventType.task_completed.value
|
||||
if task_failed:
|
||||
event_type = "task_errored"
|
||||
event_type = ProcessInstanceEventType.task_failed.value
|
||||
|
||||
# FIXME: some failed tasks will currently not have either timestamp since we only hook into spiff when tasks complete
|
||||
# which script tasks execute when READY.
|
||||
|
|
Loading…
Reference in New Issue