a couple updates for extensions w/ burnettk

This commit is contained in:
jasquat 2023-09-28 17:19:37 -04:00
parent 8f50749fa0
commit f3e7bbaa02
3 changed files with 24 additions and 16 deletions

View File

@ -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)

View File

@ -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] = []

View File

@ -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;