From f98e346954e987c4ebbaa35c27598fc3700cd391 Mon Sep 17 00:00:00 2001 From: jasquat Date: Fri, 29 Jul 2022 14:46:06 -0400 Subject: [PATCH] some fixes found while running fixing frontend acceptance tests --- bin/boot_server_in_docker | 9 ++++++++- .../services/process_instance_processor.py | 15 +++++++++++++-- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/bin/boot_server_in_docker b/bin/boot_server_in_docker index bd039722..fda4fd16 100755 --- a/bin/boot_server_in_docker +++ b/bin/boot_server_in_docker @@ -31,7 +31,14 @@ if [[ "${APPLICATION_ROOT:-}" != "/" ]]; then additional_args="${additional_args} -e SCRIPT_NAME=${APPLICATION_ROOT}" fi +# HACK: if loading fixtures for acceptance tests when we do not need multiple workers +# it causes issues with attempting to add duplicate data to the db +workers=3 +if [[ "${SPIFFWORKFLOW_BACKEND_LOAD_FIXTURE_DATA:-}" == "true" ]]; then + workers=1 +fi + export IS_GUNICORN="true" # THIS MUST BE THE LAST COMMAND! -exec poetry run gunicorn ${additional_args} --bind "0.0.0.0:$port" --workers=3 --timeout 90 --capture-output --access-logfile '-' --log-level debug wsgi:app +exec poetry run gunicorn ${additional_args} --bind "0.0.0.0:$port" --workers="$workers" --timeout 90 --capture-output --access-logfile '-' --log-level debug wsgi:app diff --git a/src/spiffworkflow_backend/services/process_instance_processor.py b/src/spiffworkflow_backend/services/process_instance_processor.py index 59e804fd..2e24499a 100644 --- a/src/spiffworkflow_backend/services/process_instance_processor.py +++ b/src/spiffworkflow_backend/services/process_instance_processor.py @@ -352,6 +352,18 @@ class ProcessInstanceProcessor: if not self.bpmn_process_instance._is_engine_task( ready_or_waiting_task.task_spec ): + + user_id = ready_or_waiting_task.data['current_user']['id'] + principal = PrincipalModel.query.filter_by(user_id=user_id).first() + if principal is None: + raise ( + ApiError( + code="principal_not_found", + message=f"Principal not found from user id: {user_id}", + status_code=400, + ) + ) + extensions = ready_or_waiting_task.task_spec.extensions form_file_name = None @@ -365,8 +377,7 @@ class ProcessInstanceProcessor: active_task = ActiveTaskModel( process_instance_id=self.process_instance_model.id, - # FIXME: look for the correct principal based on ready_or_waiting_task.lane - assigned_principal_id=PrincipalModel.query.first().id, + assigned_principal_id=principal.id, form_file_name=form_file_name, ui_form_file_name=ui_form_file_name, task_id=str(ready_or_waiting_task.id),