From ad7a4cd1e96872ea043c095a9d291b4d2f380895 Mon Sep 17 00:00:00 2001 From: Kevin Burnett <18027+burnettk@users.noreply.github.com> Date: Fri, 25 Aug 2023 05:23:33 -0700 Subject: [PATCH] handle when parent is none when getting last state change (#453) Co-authored-by: burnettk --- .../spiffworkflow_backend/data_migrations/version_1_3.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/spiffworkflow-backend/src/spiffworkflow_backend/data_migrations/version_1_3.py b/spiffworkflow-backend/src/spiffworkflow_backend/data_migrations/version_1_3.py index b7c034f7..32a9c4a3 100644 --- a/spiffworkflow-backend/src/spiffworkflow_backend/data_migrations/version_1_3.py +++ b/spiffworkflow-backend/src/spiffworkflow_backend/data_migrations/version_1_3.py @@ -1,5 +1,6 @@ import copy import json +import time import uuid from hashlib import sha256 @@ -218,7 +219,10 @@ class VersionOneThree: task_models = TaskModel.query.filter(TaskModel.properties_json.like('%last_state_change": null%')).all() # type: ignore for task_model in task_models: parent_task_model = task_model.parent_task_model() - task_model.properties_json["last_state_change"] = parent_task_model.properties_json["last_state_change"] + last_state_change = time.time() + if parent_task_model is not None: + last_state_change = parent_task_model.properties_json["last_state_change"] + task_model.properties_json["last_state_change"] = last_state_change task_model.properties_json["task_spec"] = task_model.task_definition.bpmn_identifier flag_modified(task_model, "properties_json") # type: ignore db.session.bulk_save_objects(task_models)