From f3e7bbaa0213a2a2d27709dd03c90b6fb09de90d Mon Sep 17 00:00:00 2001 From: jasquat Date: Thu, 28 Sep 2023 17:19:37 -0400 Subject: [PATCH] a couple updates for extensions w/ burnettk --- .../routes/process_instances_controller.py | 17 ++------------ .../process_instance_report_service.py | 22 +++++++++++++++++++ .../src/extension_ui_schema_interfaces.ts | 1 - 3 files changed, 24 insertions(+), 16 deletions(-) diff --git a/spiffworkflow-backend/src/spiffworkflow_backend/routes/process_instances_controller.py b/spiffworkflow-backend/src/spiffworkflow_backend/routes/process_instances_controller.py index 68afaa74..949c4c27 100644 --- a/spiffworkflow-backend/src/spiffworkflow_backend/routes/process_instances_controller.py +++ b/spiffworkflow-backend/src/spiffworkflow_backend/routes/process_instances_controller.py @@ -23,7 +23,6 @@ from spiffworkflow_backend.models.process_instance import ProcessInstanceApiSche from spiffworkflow_backend.models.process_instance import ProcessInstanceCannotBeDeletedError from spiffworkflow_backend.models.process_instance import ProcessInstanceModel from spiffworkflow_backend.models.process_instance import ProcessInstanceModelSchema -from spiffworkflow_backend.models.process_instance_metadata import ProcessInstanceMetadataModel from spiffworkflow_backend.models.process_instance_queue import ProcessInstanceQueueModel from spiffworkflow_backend.models.process_instance_report import ProcessInstanceReportModel from spiffworkflow_backend.models.process_instance_report import Report @@ -291,21 +290,9 @@ def process_instance_report_column_list( ) -> flask.wrappers.Response: table_columns = ProcessInstanceReportService.builtin_column_options() system_report_column_options = ProcessInstanceReportService.system_report_column_options() - columns_for_metadata_query = ( - db.session.query(ProcessInstanceMetadataModel.key) - .order_by(ProcessInstanceMetadataModel.key) - .distinct() # type: ignore + columns_for_metadata_strings = ProcessInstanceReportService.process_instance_metadata_as_columns( + process_model_identifier ) - if process_model_identifier: - columns_for_metadata_query = columns_for_metadata_query.join(ProcessInstanceModel) - columns_for_metadata_query = columns_for_metadata_query.filter( - ProcessInstanceModel.process_model_identifier == process_model_identifier - ) - - columns_for_metadata = columns_for_metadata_query.all() - columns_for_metadata_strings = [ - {"Header": i[0], "accessor": i[0], "filterable": True} for i in columns_for_metadata - ] return make_response(jsonify(table_columns + system_report_column_options + columns_for_metadata_strings), 200) diff --git a/spiffworkflow-backend/src/spiffworkflow_backend/services/process_instance_report_service.py b/spiffworkflow-backend/src/spiffworkflow_backend/services/process_instance_report_service.py index cd2640d6..fc72b2a6 100644 --- a/spiffworkflow-backend/src/spiffworkflow_backend/services/process_instance_report_service.py +++ b/spiffworkflow-backend/src/spiffworkflow_backend/services/process_instance_report_service.py @@ -8,6 +8,7 @@ from flask import current_app from flask_sqlalchemy.query import Query from spiffworkflow_backend.exceptions.api_error import ApiError from spiffworkflow_backend.models.db import SpiffworkflowBaseDBModel +from spiffworkflow_backend.models.db import db from spiffworkflow_backend.models.group import GroupModel from spiffworkflow_backend.models.human_task import HumanTaskModel from spiffworkflow_backend.models.human_task_user import HumanTaskUserModel @@ -181,6 +182,27 @@ class ProcessInstanceReportService: return_value: ReportMetadata = temp_system_metadata_map[metadata_key] return return_value + @classmethod + def process_instance_metadata_as_columns( + cls, process_model_identifier: str | None = None + ) -> list[ReportMetadataColumn]: + columns_for_metadata_query = ( + db.session.query(ProcessInstanceMetadataModel.key) + .order_by(ProcessInstanceMetadataModel.key) + .distinct() # type: ignore + ) + if process_model_identifier: + columns_for_metadata_query = columns_for_metadata_query.join(ProcessInstanceModel) + columns_for_metadata_query = columns_for_metadata_query.filter( + ProcessInstanceModel.process_model_identifier == process_model_identifier + ) + + columns_for_metadata = columns_for_metadata_query.all() + columns_for_metadata_strings: list[ReportMetadataColumn] = [ + {"Header": i[0], "accessor": i[0], "filterable": True} for i in columns_for_metadata + ] + return columns_for_metadata_strings + @classmethod def compile_report(cls, report_metadata: ReportMetadata, user: UserModel) -> None: compiled_filters: list[FilterValue] = [] diff --git a/spiffworkflow-frontend/src/extension_ui_schema_interfaces.ts b/spiffworkflow-frontend/src/extension_ui_schema_interfaces.ts index 867809eb..980e79d4 100644 --- a/spiffworkflow-frontend/src/extension_ui_schema_interfaces.ts +++ b/spiffworkflow-frontend/src/extension_ui_schema_interfaces.ts @@ -29,7 +29,6 @@ export interface UiSchemaForm { export interface UiSchemaAction { api_path: string; - navigate_to_on_form_submit?: string; persistence_level?: UiSchemaPersistenceLevel; process_id_to_run?: string; results_markdown_filename?: string;