From 63a0007238d982bfae66e383347ce596b4ce4b19 Mon Sep 17 00:00:00 2001 From: jasquat Date: Wed, 4 Jan 2023 13:18:05 -0500 Subject: [PATCH] pyl w/ burnettk --- .../src/spiffworkflow_backend/interfaces.py | 6 +++++- .../models/process_group.py | 3 ++- .../models/process_model.py | 2 +- .../routes/process_models_controller.py | 12 +++++++++--- .../services/process_model_service.py | 16 ++++++++++------ .../src/components/ProcessModelSearch.tsx | 1 - 6 files changed, 27 insertions(+), 13 deletions(-) diff --git a/spiffworkflow-backend/src/spiffworkflow_backend/interfaces.py b/spiffworkflow-backend/src/spiffworkflow_backend/interfaces.py index a707c22a9..3d5280420 100644 --- a/spiffworkflow-backend/src/spiffworkflow_backend/interfaces.py +++ b/spiffworkflow-backend/src/spiffworkflow_backend/interfaces.py @@ -1,5 +1,7 @@ -from typing import NewType, TypedDict +"""Interfaces.""" +from typing import NewType from typing import TYPE_CHECKING +from typing import TypedDict if TYPE_CHECKING: from spiffworkflow_backend.models.process_group import ProcessGroup @@ -9,12 +11,14 @@ IdToProcessGroupMapping = NewType("IdToProcessGroupMapping", dict[str, "ProcessG class ProcessGroupLite(TypedDict): + """ProcessGroupLite.""" id: str display_name: str class ProcessGroupLitesWithCache(TypedDict): + """ProcessGroupLitesWithCache.""" cache: dict[str, "ProcessGroup"] process_groups: list[ProcessGroupLite] diff --git a/spiffworkflow-backend/src/spiffworkflow_backend/models/process_group.py b/spiffworkflow-backend/src/spiffworkflow_backend/models/process_group.py index 1439b0459..63c851a5b 100644 --- a/spiffworkflow-backend/src/spiffworkflow_backend/models/process_group.py +++ b/spiffworkflow-backend/src/spiffworkflow_backend/models/process_group.py @@ -11,6 +11,7 @@ import marshmallow from marshmallow import post_load from marshmallow import Schema +from spiffworkflow_backend.interfaces import ProcessGroupLite from spiffworkflow_backend.models.process_model import ProcessModelInfo @@ -29,7 +30,7 @@ class ProcessGroup: default_factory=list[ProcessModelInfo] ) process_groups: list[ProcessGroup] = field(default_factory=list["ProcessGroup"]) - parent_groups: list[dict] | None = None + parent_groups: list[ProcessGroupLite] | None = None def __post_init__(self) -> None: """__post_init__.""" diff --git a/spiffworkflow-backend/src/spiffworkflow_backend/models/process_model.py b/spiffworkflow-backend/src/spiffworkflow_backend/models/process_model.py index 0b3ffa230..c737b274b 100644 --- a/spiffworkflow-backend/src/spiffworkflow_backend/models/process_model.py +++ b/spiffworkflow-backend/src/spiffworkflow_backend/models/process_model.py @@ -10,8 +10,8 @@ from typing import Any import marshmallow from marshmallow import Schema from marshmallow.decorators import post_load -from spiffworkflow_backend.interfaces import ProcessGroupLite +from spiffworkflow_backend.interfaces import ProcessGroupLite from spiffworkflow_backend.models.file import File diff --git a/spiffworkflow-backend/src/spiffworkflow_backend/routes/process_models_controller.py b/spiffworkflow-backend/src/spiffworkflow_backend/routes/process_models_controller.py index ac6514155..1709357a7 100644 --- a/spiffworkflow-backend/src/spiffworkflow_backend/routes/process_models_controller.py +++ b/spiffworkflow-backend/src/spiffworkflow_backend/routes/process_models_controller.py @@ -15,8 +15,8 @@ from flask import jsonify from flask import make_response from flask.wrappers import Response from flask_bpmn.api.api_error import ApiError -from spiffworkflow_backend.interfaces import IdToProcessGroupMapping +from spiffworkflow_backend.interfaces import IdToProcessGroupMapping from spiffworkflow_backend.models.file import FileSchema from spiffworkflow_backend.models.process_group import ProcessGroup from spiffworkflow_backend.models.process_instance_report import ( @@ -190,8 +190,14 @@ def process_model_list( if include_parent_groups: process_group_cache = IdToProcessGroupMapping({}) for process_model in process_models_to_return: - parent_group_lites_with_cache = ProcessModelService.get_parent_group_array_and_cache_it(process_model.id, process_group_cache) - process_model.parent_groups = parent_group_lites_with_cache['process_groups'] + parent_group_lites_with_cache = ( + ProcessModelService.get_parent_group_array_and_cache_it( + process_model.id, process_group_cache + ) + ) + process_model.parent_groups = parent_group_lites_with_cache[ + "process_groups" + ] pages = len(process_models) // per_page remainder = len(process_models) % per_page diff --git a/spiffworkflow-backend/src/spiffworkflow_backend/services/process_model_service.py b/spiffworkflow-backend/src/spiffworkflow_backend/services/process_model_service.py index c81b0e815..8fa25bc08 100644 --- a/spiffworkflow-backend/src/spiffworkflow_backend/services/process_model_service.py +++ b/spiffworkflow-backend/src/spiffworkflow_backend/services/process_model_service.py @@ -1,6 +1,5 @@ """Process_model_service.""" import json -from typing import TypedDict import os import shutil from glob import glob @@ -14,7 +13,8 @@ from flask_bpmn.api.api_error import ApiError from spiffworkflow_backend.exceptions.process_entity_not_found_error import ( ProcessEntityNotFoundError, ) -from spiffworkflow_backend.interfaces import ProcessGroupLite, ProcessGroupLitesWithCache +from spiffworkflow_backend.interfaces import ProcessGroupLite +from spiffworkflow_backend.interfaces import ProcessGroupLitesWithCache from spiffworkflow_backend.models.process_group import ProcessGroup from spiffworkflow_backend.models.process_group import ProcessGroupSchema from spiffworkflow_backend.models.process_instance import ProcessInstanceModel @@ -239,7 +239,9 @@ class ProcessModelService(FileSystemService): return process_models @classmethod - def get_parent_group_array_and_cache_it(cls, process_identifier: str, process_group_cache: dict[str, ProcessGroup]) -> ProcessGroupLitesWithCache: + def get_parent_group_array_and_cache_it( + cls, process_identifier: str, process_group_cache: dict[str, ProcessGroup] + ) -> ProcessGroupLitesWithCache: """Get_parent_group_array.""" full_group_id_path = None parent_group_array: list[ProcessGroupLite] = [] @@ -258,13 +260,15 @@ class ProcessModelService(FileSystemService): parent_group_array.append( {"id": parent_group.id, "display_name": parent_group.display_name} ) - return {'cache': process_group_cache, 'process_groups': parent_group_array} + return {"cache": process_group_cache, "process_groups": parent_group_array} @classmethod def get_parent_group_array(cls, process_identifier: str) -> list[ProcessGroupLite]: """Get_parent_group_array.""" - parent_group_lites_with_cache = cls.get_parent_group_array_and_cache_it(process_identifier, {}) - return parent_group_lites_with_cache['process_groups'] + parent_group_lites_with_cache = cls.get_parent_group_array_and_cache_it( + process_identifier, {} + ) + return parent_group_lites_with_cache["process_groups"] @classmethod def get_process_groups( diff --git a/spiffworkflow-frontend/src/components/ProcessModelSearch.tsx b/spiffworkflow-frontend/src/components/ProcessModelSearch.tsx index 790dff2e6..bd995bc3e 100644 --- a/spiffworkflow-frontend/src/components/ProcessModelSearch.tsx +++ b/spiffworkflow-frontend/src/components/ProcessModelSearch.tsx @@ -2,7 +2,6 @@ import { ComboBox, // @ts-ignore } from '@carbon/react'; -import { truncateString } from '../helpers'; import { ProcessGroupLite, ProcessModel } from '../interfaces'; type OwnProps = {