From 3cbb4e986abc6a3ca041bc9bfb30f42fb0cd6b5c Mon Sep 17 00:00:00 2001 From: jasquat Date: Mon, 14 Nov 2022 10:17:18 -0500 Subject: [PATCH] pyl w/ burnettk --- .../models/message_correlation.py | 4 +--- .../routes/process_api_blueprint.py | 24 ++++++++++++------- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/spiffworkflow-backend/src/spiffworkflow_backend/models/message_correlation.py b/spiffworkflow-backend/src/spiffworkflow_backend/models/message_correlation.py index c8c28aab..08bc1cb1 100644 --- a/spiffworkflow-backend/src/spiffworkflow_backend/models/message_correlation.py +++ b/spiffworkflow-backend/src/spiffworkflow_backend/models/message_correlation.py @@ -44,9 +44,7 @@ class MessageCorrelationModel(SpiffworkflowBaseDBModel): updated_at_in_seconds: int = db.Column(db.Integer) created_at_in_seconds: int = db.Column(db.Integer) - message_correlation_property = relationship( - "MessageCorrelationPropertyModel" - ) + message_correlation_property = relationship("MessageCorrelationPropertyModel") message_correlations_message_instances = relationship( "MessageCorrelationMessageInstanceModel", cascade="delete" ) diff --git a/spiffworkflow-backend/src/spiffworkflow_backend/routes/process_api_blueprint.py b/spiffworkflow-backend/src/spiffworkflow_backend/routes/process_api_blueprint.py index dfbb2a4d..98f8abce 100644 --- a/spiffworkflow-backend/src/spiffworkflow_backend/routes/process_api_blueprint.py +++ b/spiffworkflow-backend/src/spiffworkflow_backend/routes/process_api_blueprint.py @@ -1,5 +1,4 @@ """APIs for dealing with process groups, process models, and process instances.""" -import dataclasses import json import os import random @@ -14,10 +13,6 @@ from typing import Union import connexion # type: ignore import flask.wrappers import jinja2 -from spiffworkflow_backend.models import message_correlation_message_instance -from spiffworkflow_backend.models.message_correlation import MessageCorrelationModel -from spiffworkflow_backend.models.message_correlation_message_instance import MessageCorrelationMessageInstanceModel -from spiffworkflow_backend.models.message_correlation_property import MessageCorrelationPropertyModel import werkzeug from flask import Blueprint from flask import current_app @@ -44,6 +39,7 @@ from spiffworkflow_backend.models.active_task import ActiveTaskModel from spiffworkflow_backend.models.active_task_user import ActiveTaskUserModel from spiffworkflow_backend.models.file import FileSchema from spiffworkflow_backend.models.group import GroupModel +from spiffworkflow_backend.models.message_correlation import MessageCorrelationModel from spiffworkflow_backend.models.message_instance import MessageInstanceModel from spiffworkflow_backend.models.message_model import MessageModel from spiffworkflow_backend.models.message_triggerable_process_model import ( @@ -597,13 +593,23 @@ def message_instance_list( for message_instance in message_instances: message_correlations: dict = {} - for mcmi in message_instance.MessageInstanceModel.message_correlations_message_instances: - mc = MessageCorrelationModel.query.filter_by(id=mcmi.message_correlation_id).all() + for ( + mcmi + ) in ( + message_instance.MessageInstanceModel.message_correlations_message_instances + ): + mc = MessageCorrelationModel.query.filter_by( + id=mcmi.message_correlation_id + ).all() for m in mc: if m.name not in message_correlations: message_correlations[m.name] = {} - message_correlations[m.name][m.message_correlation_property.identifier] = m.value - message_instance.MessageInstanceModel.message_correlations = message_correlations + message_correlations[m.name][ + m.message_correlation_property.identifier + ] = m.value + message_instance.MessageInstanceModel.message_correlations = ( + message_correlations + ) response_json = { "results": message_instances.items,