only delete active tasks if needed w/ burnettk cullerton
This commit is contained in:
parent
692bd00e46
commit
59aacf05a8
|
@ -590,16 +590,12 @@ class ProcessInstanceProcessor:
|
||||||
if self.bpmn_process_instance.is_completed():
|
if self.bpmn_process_instance.is_completed():
|
||||||
self.process_instance_model.end_in_seconds = round(time.time())
|
self.process_instance_model.end_in_seconds = round(time.time())
|
||||||
|
|
||||||
active_tasks = ActiveTaskModel.query.filter_by(
|
|
||||||
process_instance_id=self.process_instance_model.id
|
|
||||||
).all()
|
|
||||||
if len(active_tasks) > 0:
|
|
||||||
for at in active_tasks:
|
|
||||||
db.session.delete(at)
|
|
||||||
|
|
||||||
db.session.add(self.process_instance_model)
|
db.session.add(self.process_instance_model)
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
|
|
||||||
|
active_tasks = ActiveTaskModel.query.filter_by(
|
||||||
|
process_instance_id=self.process_instance_model.id
|
||||||
|
).all()
|
||||||
ready_or_waiting_tasks = self.get_all_ready_or_waiting_tasks()
|
ready_or_waiting_tasks = self.get_all_ready_or_waiting_tasks()
|
||||||
for ready_or_waiting_task in ready_or_waiting_tasks:
|
for ready_or_waiting_task in ready_or_waiting_tasks:
|
||||||
# filter out non-usertasks
|
# filter out non-usertasks
|
||||||
|
@ -626,20 +622,27 @@ class ProcessInstanceProcessor:
|
||||||
if process_model_info is not None:
|
if process_model_info is not None:
|
||||||
process_model_display_name = process_model_info.display_name
|
process_model_display_name = process_model_info.display_name
|
||||||
|
|
||||||
active_task = ActiveTaskModel(
|
active_task = None
|
||||||
process_instance_id=self.process_instance_model.id,
|
for at in active_tasks:
|
||||||
process_model_display_name=process_model_display_name,
|
if at.task_id == str(ready_or_waiting_task.id):
|
||||||
form_file_name=form_file_name,
|
active_task = at
|
||||||
ui_form_file_name=ui_form_file_name,
|
active_tasks.pop(at)
|
||||||
task_id=str(ready_or_waiting_task.id),
|
|
||||||
task_name=ready_or_waiting_task.task_spec.name,
|
if active_task is None:
|
||||||
task_title=ready_or_waiting_task.task_spec.description,
|
active_task = ActiveTaskModel(
|
||||||
task_type=ready_or_waiting_task.task_spec.__class__.__name__,
|
process_instance_id=self.process_instance_model.id,
|
||||||
task_status=ready_or_waiting_task.get_state_name(),
|
process_model_display_name=process_model_display_name,
|
||||||
lane_assignment_id=potential_owner_hash["lane_assignment_id"],
|
form_file_name=form_file_name,
|
||||||
)
|
ui_form_file_name=ui_form_file_name,
|
||||||
db.session.add(active_task)
|
task_id=str(ready_or_waiting_task.id),
|
||||||
db.session.commit()
|
task_name=ready_or_waiting_task.task_spec.name,
|
||||||
|
task_title=ready_or_waiting_task.task_spec.description,
|
||||||
|
task_type=ready_or_waiting_task.task_spec.__class__.__name__,
|
||||||
|
task_status=ready_or_waiting_task.get_state_name(),
|
||||||
|
lane_assignment_id=potential_owner_hash["lane_assignment_id"],
|
||||||
|
)
|
||||||
|
db.session.add(active_task)
|
||||||
|
db.session.commit()
|
||||||
|
|
||||||
for potential_owner_id in potential_owner_hash["potential_owner_ids"]:
|
for potential_owner_id in potential_owner_hash["potential_owner_ids"]:
|
||||||
active_task_user = ActiveTaskUserModel(
|
active_task_user = ActiveTaskUserModel(
|
||||||
|
@ -648,6 +651,11 @@ class ProcessInstanceProcessor:
|
||||||
db.session.add(active_task_user)
|
db.session.add(active_task_user)
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
|
|
||||||
|
if len(active_tasks) > 0:
|
||||||
|
for at in active_tasks:
|
||||||
|
db.session.delete(at)
|
||||||
|
db.session.commit()
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_parser() -> MyCustomParser:
|
def get_parser() -> MyCustomParser:
|
||||||
"""Get_parser."""
|
"""Get_parser."""
|
||||||
|
|
Loading…
Reference in New Issue