mirror of
https://github.com/sartography/spiff-arena.git
synced 2025-02-12 01:16:58 +00:00
added migration to increase column size of task names and added some truncation to avoid unnecessary errors w/ burnettk (#2045)
Co-authored-by: jasquat <jasquat@users.noreply.github.com>
This commit is contained in:
parent
2d984ee21e
commit
a74e19bee8
50
spiffworkflow-backend/migrations/versions/b9a7cf115630_.py
Normal file
50
spiffworkflow-backend/migrations/versions/b9a7cf115630_.py
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
"""empty message
|
||||||
|
|
||||||
|
Revision ID: b9a7cf115630
|
||||||
|
Revises: f318f9f1b110
|
||||||
|
Create Date: 2024-08-12 15:17:40.990772
|
||||||
|
|
||||||
|
"""
|
||||||
|
from alembic import op
|
||||||
|
import sqlalchemy as sa
|
||||||
|
from sqlalchemy.dialects import mysql
|
||||||
|
|
||||||
|
# revision identifiers, used by Alembic.
|
||||||
|
revision = 'b9a7cf115630'
|
||||||
|
down_revision = 'f318f9f1b110'
|
||||||
|
branch_labels = None
|
||||||
|
depends_on = None
|
||||||
|
|
||||||
|
|
||||||
|
def upgrade():
|
||||||
|
# ### commands auto generated by Alembic - please adjust! ###
|
||||||
|
with op.batch_alter_table('human_task', schema=None) as batch_op:
|
||||||
|
batch_op.alter_column('task_title',
|
||||||
|
existing_type=mysql.VARCHAR(collation='utf8mb4_0900_as_cs', length=50),
|
||||||
|
type_=sa.String(length=255),
|
||||||
|
existing_nullable=True)
|
||||||
|
|
||||||
|
with op.batch_alter_table('human_task_user', schema=None) as batch_op:
|
||||||
|
batch_op.alter_column('added_by',
|
||||||
|
existing_type=mysql.VARCHAR(collation='utf8mb4_0900_as_cs', length=50),
|
||||||
|
type_=sa.String(length=20),
|
||||||
|
existing_nullable=True)
|
||||||
|
|
||||||
|
# ### end Alembic commands ###
|
||||||
|
|
||||||
|
|
||||||
|
def downgrade():
|
||||||
|
# ### commands auto generated by Alembic - please adjust! ###
|
||||||
|
with op.batch_alter_table('human_task_user', schema=None) as batch_op:
|
||||||
|
batch_op.alter_column('added_by',
|
||||||
|
existing_type=sa.String(length=20),
|
||||||
|
type_=mysql.VARCHAR(collation='utf8mb4_0900_as_cs', length=50),
|
||||||
|
existing_nullable=True)
|
||||||
|
|
||||||
|
with op.batch_alter_table('human_task', schema=None) as batch_op:
|
||||||
|
batch_op.alter_column('task_title',
|
||||||
|
existing_type=sa.String(length=255),
|
||||||
|
type_=mysql.VARCHAR(collation='utf8mb4_0900_as_cs', length=50),
|
||||||
|
existing_nullable=True)
|
||||||
|
|
||||||
|
# ### end Alembic commands ###
|
@ -44,9 +44,9 @@ class HumanTaskModel(SpiffworkflowBaseDBModel):
|
|||||||
task_guid: str = db.Column(ForeignKey(TaskModel.guid), nullable=True, index=True)
|
task_guid: str = db.Column(ForeignKey(TaskModel.guid), nullable=True, index=True)
|
||||||
task_model = relationship(TaskModel)
|
task_model = relationship(TaskModel)
|
||||||
|
|
||||||
task_id: str = db.Column(db.String(50))
|
task_id: str = db.Column(db.String(50)) # guid
|
||||||
task_name: str = db.Column(db.String(255))
|
task_name: str = db.Column(db.String(255)) # bpmn id
|
||||||
task_title: str = db.Column(db.String(50))
|
task_title: str | None = db.Column(db.String(255)) # bpmn name
|
||||||
task_type: str = db.Column(db.String(50))
|
task_type: str = db.Column(db.String(50))
|
||||||
task_status: str = db.Column(db.String(50))
|
task_status: str = db.Column(db.String(50))
|
||||||
process_model_display_name: str = db.Column(db.String(255))
|
process_model_display_name: str = db.Column(db.String(255))
|
||||||
@ -78,7 +78,7 @@ class HumanTaskModel(SpiffworkflowBaseDBModel):
|
|||||||
new_task = Task(
|
new_task = Task(
|
||||||
task.task_guid,
|
task.task_guid,
|
||||||
task.task_name,
|
task.task_name,
|
||||||
task.task_title,
|
task.task_title or "",
|
||||||
task.task_type,
|
task.task_type,
|
||||||
task.task_status,
|
task.task_status,
|
||||||
can_complete,
|
can_complete,
|
||||||
|
@ -31,7 +31,7 @@ class TaskDefinitionModel(SpiffworkflowBaseDBModel):
|
|||||||
bpmn_process_definition = relationship(BpmnProcessDefinitionModel)
|
bpmn_process_definition = relationship(BpmnProcessDefinitionModel)
|
||||||
|
|
||||||
bpmn_identifier: str = db.Column(db.String(255), nullable=False, index=True)
|
bpmn_identifier: str = db.Column(db.String(255), nullable=False, index=True)
|
||||||
bpmn_name: str = db.Column(db.String(255), nullable=True, index=True)
|
bpmn_name: str | None = db.Column(db.String(255), nullable=True, index=True)
|
||||||
typename: str = db.Column(db.String(255), nullable=False, index=True)
|
typename: str = db.Column(db.String(255), nullable=False, index=True)
|
||||||
|
|
||||||
properties_json: dict = db.Column(db.JSON, nullable=False)
|
properties_json: dict = db.Column(db.JSON, nullable=False)
|
||||||
|
@ -1040,14 +1040,14 @@ class ProcessInstanceProcessor:
|
|||||||
process_instance_id=self.process_instance_model.id,
|
process_instance_id=self.process_instance_model.id,
|
||||||
key=key,
|
key=key,
|
||||||
)
|
)
|
||||||
pim.value = str(data_for_key)[0:255]
|
pim.value = self.__class__.truncate_string(str(data_for_key), 255)
|
||||||
db.session.add(pim)
|
db.session.add(pim)
|
||||||
|
|
||||||
def update_summary(self) -> None:
|
def update_summary(self) -> None:
|
||||||
current_data = self.get_current_data()
|
current_data = self.get_current_data()
|
||||||
if "spiff_process_instance_summary" in current_data:
|
if "spiff_process_instance_summary" in current_data:
|
||||||
summary = current_data["spiff_process_instance_summary"]
|
summary = current_data["spiff_process_instance_summary"]
|
||||||
self.process_instance_model.summary = summary[:255]
|
self.process_instance_model.summary = self.__class__.truncate_string(summary, 255)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def _store_bpmn_process_definition(
|
def _store_bpmn_process_definition(
|
||||||
@ -1090,10 +1090,12 @@ class ProcessInstanceProcessor:
|
|||||||
)
|
)
|
||||||
for task_bpmn_identifier, task_bpmn_properties in task_specs.items():
|
for task_bpmn_identifier, task_bpmn_properties in task_specs.items():
|
||||||
task_bpmn_name = task_bpmn_properties["bpmn_name"]
|
task_bpmn_name = task_bpmn_properties["bpmn_name"]
|
||||||
|
truncated_name = cls.truncate_string(task_bpmn_name, 255)
|
||||||
|
task_bpmn_properties["bpmn_name"] = truncated_name
|
||||||
task_definition = TaskDefinitionModel(
|
task_definition = TaskDefinitionModel(
|
||||||
bpmn_process_definition=bpmn_process_definition,
|
bpmn_process_definition=bpmn_process_definition,
|
||||||
bpmn_identifier=task_bpmn_identifier,
|
bpmn_identifier=task_bpmn_identifier,
|
||||||
bpmn_name=task_bpmn_name,
|
bpmn_name=truncated_name,
|
||||||
properties_json=task_bpmn_properties,
|
properties_json=task_bpmn_properties,
|
||||||
typename=task_bpmn_properties["typename"],
|
typename=task_bpmn_properties["typename"],
|
||||||
)
|
)
|
||||||
@ -1171,6 +1173,12 @@ class ProcessInstanceProcessor:
|
|||||||
)
|
)
|
||||||
process_instance_model.bpmn_process_definition = bpmn_process_definition_parent
|
process_instance_model.bpmn_process_definition = bpmn_process_definition_parent
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def truncate_string(cls, input_string: str | None, max_length: int) -> str | None:
|
||||||
|
if input_string is None:
|
||||||
|
return None
|
||||||
|
return input_string[:max_length]
|
||||||
|
|
||||||
def save(self) -> None:
|
def save(self) -> None:
|
||||||
"""Saves the current state of this processor to the database."""
|
"""Saves the current state of this processor to the database."""
|
||||||
self.process_instance_model.spiff_serializer_version = SPIFFWORKFLOW_BACKEND_SERIALIZER_VERSION
|
self.process_instance_model.spiff_serializer_version = SPIFFWORKFLOW_BACKEND_SERIALIZER_VERSION
|
||||||
@ -1240,7 +1248,7 @@ class ProcessInstanceProcessor:
|
|||||||
task_guid=task_model.guid,
|
task_guid=task_model.guid,
|
||||||
task_id=task_guid,
|
task_id=task_guid,
|
||||||
task_name=ready_or_waiting_task.task_spec.bpmn_id,
|
task_name=ready_or_waiting_task.task_spec.bpmn_id,
|
||||||
task_title=ready_or_waiting_task.task_spec.bpmn_name,
|
task_title=self.__class__.truncate_string(ready_or_waiting_task.task_spec.bpmn_name, 255),
|
||||||
task_type=ready_or_waiting_task.task_spec.__class__.__name__,
|
task_type=ready_or_waiting_task.task_spec.__class__.__name__,
|
||||||
task_status=TaskState.get_name(ready_or_waiting_task.state),
|
task_status=TaskState.get_name(ready_or_waiting_task.state),
|
||||||
lane_assignment_id=potential_owner_hash["lane_assignment_id"],
|
lane_assignment_id=potential_owner_hash["lane_assignment_id"],
|
||||||
|
Loading…
x
Reference in New Issue
Block a user