always save the serialized bpmn definition for now w/ burnettk

This commit is contained in:
jasquat 2023-03-01 15:01:29 -05:00
parent d1b8de9ea3
commit 53486823b6
1 changed files with 20 additions and 12 deletions

View File

@ -874,18 +874,24 @@ class ProcessInstanceProcessor:
else:
process_instance_data_dict[bpmn_key] = bpmn_dict[bpmn_key]
if self.process_instance_model.serialized_bpmn_definition_id is None:
new_hash_digest = sha256(
json.dumps(bpmn_spec_dict, sort_keys=True).encode("utf8")
).hexdigest()
serialized_bpmn_definition = SerializedBpmnDefinitionModel.query.filter_by(
hash=new_hash_digest
).first()
if serialized_bpmn_definition is None:
serialized_bpmn_definition = SerializedBpmnDefinitionModel(
hash=new_hash_digest, static_json=json.dumps(bpmn_spec_dict)
)
db.session.add(serialized_bpmn_definition)
# FIXME: always save new hash until we get updated Spiff without loopresettask
# if self.process_instance_model.serialized_bpmn_definition_id is None:
new_hash_digest = sha256(
json.dumps(bpmn_spec_dict, sort_keys=True).encode("utf8")
).hexdigest()
serialized_bpmn_definition = SerializedBpmnDefinitionModel.query.filter_by(
hash=new_hash_digest
).first()
if serialized_bpmn_definition is None:
serialized_bpmn_definition = SerializedBpmnDefinitionModel(
hash=new_hash_digest, static_json=json.dumps(bpmn_spec_dict)
)
db.session.add(serialized_bpmn_definition)
if (
self.process_instance_model.serialized_bpmn_definition_id is None
or self.process_instance_model.serialized_bpmn_definition.hash
!= new_hash_digest
):
self.process_instance_model.serialized_bpmn_definition = (
serialized_bpmn_definition
)
@ -1299,6 +1305,8 @@ class ProcessInstanceProcessor:
return ProcessInstanceStatus.complete
user_tasks = bpmn_process_instance.get_ready_user_tasks()
# workflow.waiting_events (includes timers, and timers have a when firing property)
# if the process instance has status "waiting" it will get picked up
# by background processing. when that happens it can potentially overwrite
# human tasks which is bad because we cache them with the previous id's.