Change process_instance.status column to string
Add `faulted` and `suspended` to ProcessInstanceStatus Fix services and models to match this change
This commit is contained in:
parent
792e6eaedc
commit
cc43ec5510
|
@ -60,7 +60,7 @@ def upgrade():
|
|||
sa.Column('end_in_seconds', sa.Integer(), nullable=True),
|
||||
sa.Column('updated_at_in_seconds', sa.Integer(), nullable=True),
|
||||
sa.Column('created_at_in_seconds', sa.Integer(), nullable=True),
|
||||
sa.Column('status', sa.Enum('not_started', 'user_input_required', 'waiting', 'complete', 'erroring', name='processinstancestatus'), nullable=True),
|
||||
sa.Column('status', sa.String(length=50), nullable=True),
|
||||
sa.ForeignKeyConstraint(['process_initiator_id'], ['user.id'], ),
|
||||
sa.PrimaryKeyConstraint('id')
|
||||
)
|
||||
|
|
|
@ -337,7 +337,7 @@ paths:
|
|||
- name: process_status
|
||||
in: query
|
||||
required: false
|
||||
description: For filtering - not_started, user_input_required, waiting, complete, or erroring
|
||||
description: For filtering - not_started, user_input_required, waiting, complete, faulted, or suspended
|
||||
schema:
|
||||
type: string
|
||||
# process_instance_list
|
||||
|
|
|
@ -72,7 +72,8 @@ class ProcessInstanceStatus(enum.Enum):
|
|||
user_input_required = "user_input_required"
|
||||
waiting = "waiting"
|
||||
complete = "complete"
|
||||
erroring = "erroring"
|
||||
faulted = "faulted"
|
||||
suspended = "suspended"
|
||||
|
||||
|
||||
class ProcessInstanceModel(SpiffworkflowBaseDBModel):
|
||||
|
@ -90,7 +91,7 @@ class ProcessInstanceModel(SpiffworkflowBaseDBModel):
|
|||
end_in_seconds: int | None = db.Column(db.Integer) # type: ignore
|
||||
updated_at_in_seconds: int = db.Column(db.Integer) # type: ignore
|
||||
created_at_in_seconds: int = db.Column(db.Integer) # type: ignore
|
||||
status: ProcessInstanceStatus = db.Column(db.Enum(ProcessInstanceStatus)) # type: ignore
|
||||
status: str = db.Column(db.String()) # type: ignore
|
||||
|
||||
@property
|
||||
def serialized(self) -> dict[str, int | str | None]:
|
||||
|
@ -99,7 +100,7 @@ class ProcessInstanceModel(SpiffworkflowBaseDBModel):
|
|||
"id": self.id,
|
||||
"process_model_identifier": self.process_model_identifier,
|
||||
"process_group_identifier": self.process_group_identifier,
|
||||
"status": self.status.value,
|
||||
"status": self.status,
|
||||
"bpmn_json": self.bpmn_json,
|
||||
"start_in_seconds": self.start_in_seconds,
|
||||
"end_in_seconds": self.end_in_seconds,
|
||||
|
@ -128,7 +129,7 @@ class ProcessInstanceModelSchema(Schema):
|
|||
status = marshmallow.fields.Method('get_status', dump_only=True)
|
||||
|
||||
def get_status(self, obj):
|
||||
return obj.status.value
|
||||
return obj.status
|
||||
|
||||
|
||||
class ProcessInstanceApi:
|
||||
|
|
|
@ -40,7 +40,7 @@ class ProcessModelInfo:
|
|||
display_order: int | None = 0
|
||||
is_review: bool = False
|
||||
files: list[File] | None = field(default_factory=list[File])
|
||||
fault_or_suspend_on_exception: NotificationType = NotificationType.suspend
|
||||
fault_or_suspend_on_exception: NotificationType = NotificationType.fault.value
|
||||
notification_email_on_exception: list[str] = field(default_factory=list)
|
||||
|
||||
def __post_init__(self) -> None:
|
||||
|
|
|
@ -317,7 +317,7 @@ class ProcessInstanceProcessor:
|
|||
self.process_instance_model.bpmn_json = self.serialize()
|
||||
complete_states = [TaskState.CANCELLED, TaskState.COMPLETED]
|
||||
user_tasks = list(self.get_all_user_tasks())
|
||||
self.process_instance_model.status = self.get_status()
|
||||
self.process_instance_model.status = self.get_status().value
|
||||
self.process_instance_model.total_tasks = len(user_tasks)
|
||||
self.process_instance_model.completed_tasks = sum(
|
||||
1 for t in user_tasks if t.state in complete_states
|
||||
|
|
|
@ -34,7 +34,7 @@ class ProcessInstanceService:
|
|||
) -> ProcessInstanceModel:
|
||||
"""Get_process_instance_from_spec."""
|
||||
process_instance_model = ProcessInstanceModel(
|
||||
status=ProcessInstanceStatus.not_started,
|
||||
status=ProcessInstanceStatus.not_started.value,
|
||||
process_initiator=user,
|
||||
process_model_identifier=process_model_identifier,
|
||||
process_group_identifier=process_group_identifier,
|
||||
|
|
|
@ -670,12 +670,12 @@ def test_process_instance_list_filter(
|
|||
test_process_model_id = "sample"
|
||||
user = find_or_create_user()
|
||||
load_test_spec(test_process_model_id, process_group_id=test_process_group_id)
|
||||
statuses = ("not_started", "user_input_required", "waiting", "complete", "erroring")
|
||||
|
||||
statuses = [status.value for status in ProcessInstanceStatus]
|
||||
# create 5 instances with different status, and different start_in_seconds/end_in_seconds
|
||||
for i in range(5):
|
||||
process_instance = ProcessInstanceModel(
|
||||
status=ProcessInstanceStatus[statuses[i]],
|
||||
status=ProcessInstanceStatus[statuses[i]].value,
|
||||
process_initiator=user,
|
||||
process_model_identifier=test_process_model_id,
|
||||
process_group_identifier=test_process_group_id,
|
||||
|
|
Loading…
Reference in New Issue