cherry-picked 81b6431c58
into main for task_guid backfill fix
This commit is contained in:
parent
75a1d19586
commit
4983d48f22
|
@ -61,6 +61,15 @@ def remove_duplicate_human_task_rows() -> None:
|
|||
db.session.commit()
|
||||
|
||||
|
||||
@benchmark_log_func
|
||||
def backfill_task_guid_for_human_tasks() -> None:
|
||||
update_query = (
|
||||
update(HumanTaskModel).where(HumanTaskModel.task_guid == None).values(task_guid=HumanTaskModel.task_id) # noqa: E711
|
||||
)
|
||||
db.session.execute(update_query)
|
||||
db.session.commit()
|
||||
|
||||
|
||||
def all_potentially_relevant_process_instances() -> list[ProcessInstanceModel]:
|
||||
return ProcessInstanceModel.query.filter(
|
||||
ProcessInstanceModel.spiff_serializer_version < Version2.version(),
|
||||
|
@ -88,6 +97,7 @@ def main() -> None:
|
|||
start_time = time.time()
|
||||
put_serializer_version_onto_numeric_track()
|
||||
remove_duplicate_human_task_rows()
|
||||
backfill_task_guid_for_human_tasks()
|
||||
process_instances = all_potentially_relevant_process_instances()
|
||||
potentially_relevant_instance_count = len(process_instances)
|
||||
current_app.logger.debug(f"Found potentially relevant process_instances: {potentially_relevant_instance_count}")
|
||||
|
|
|
@ -1,21 +0,0 @@
|
|||
import time
|
||||
|
||||
from spiffworkflow_backend import create_app
|
||||
from spiffworkflow_backend.data_migrations.version_1_3 import VersionOneThree
|
||||
|
||||
|
||||
def main() -> None:
|
||||
app = create_app()
|
||||
start_time = time.time()
|
||||
|
||||
with app.app_context():
|
||||
VersionOneThree().run()
|
||||
|
||||
end_time = time.time()
|
||||
app.logger.debug(
|
||||
f"done running data migration from ./bin/data_migrations/version_1_3.py. took {end_time - start_time} seconds"
|
||||
)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
|
@ -925,9 +925,15 @@ def _task_submit_shared(
|
|||
human_task=human_task,
|
||||
)
|
||||
|
||||
# currently task_model has the potential to be None. This should be removable once
|
||||
# we backfill the human_task table for task_guid and make that column not nullable
|
||||
task_model: TaskModel | None = human_task.task_model
|
||||
if task_model is None:
|
||||
task_model = TaskModel.query.filter_by(guid=human_task.task_id).first()
|
||||
|
||||
# delete draft data when we submit a task to ensure cycling back to the task contains the
|
||||
# most up-to-date data
|
||||
task_draft_data = TaskService.task_draft_data_from_task_model(human_task.task_model)
|
||||
task_draft_data = TaskService.task_draft_data_from_task_model(task_model)
|
||||
if task_draft_data is not None:
|
||||
db.session.delete(task_draft_data)
|
||||
db.session.commit()
|
||||
|
|
Loading…
Reference in New Issue