finished base for metadata reporting w/ burnettk

This commit is contained in:
jasquat 2022-11-29 16:37:19 -05:00
parent 88c6d625bb
commit 83032deb9a
2 changed files with 8 additions and 12 deletions

View File

@ -940,19 +940,17 @@ def process_instance_list(
if column["accessor"] in stock_columns:
continue
instance_metadata_alias = aliased(ProcessInstanceMetadataModel)
process_instance_query = (
process_instance_query.outerjoin(
instance_metadata_alias,
process_instance_query = process_instance_query.outerjoin(
instance_metadata_alias,
and_(
ProcessInstanceModel.id == instance_metadata_alias.process_instance_id,
)
.filter(instance_metadata_alias.key == column["accessor"])
.add_columns(
func.max(instance_metadata_alias.value).label(column["accessor"])
)
)
instance_metadata_alias.key == column["accessor"],
),
).add_columns(func.max(instance_metadata_alias.value).label(column["accessor"]))
process_instances = (
process_instance_query.group_by(ProcessInstanceModel.id)
.add_columns(ProcessInstanceModel.id)
.order_by(
ProcessInstanceModel.start_in_seconds.desc(), ProcessInstanceModel.id.desc() # type: ignore
)

View File

@ -5,7 +5,6 @@ from typing import Optional
import sqlalchemy
from flask_bpmn.models.db import db
from spiffworkflow_backend.models.process_instance import ProcessInstanceModel
from spiffworkflow_backend.models.process_instance_report import (
ProcessInstanceReportModel,
)
@ -253,12 +252,11 @@ class ProcessInstanceReportService:
metadata_columns: list[dict],
) -> list[dict]:
"""Add_metadata_columns_to_process_instance."""
stock_columns = cls.get_column_names_for_model(ProcessInstanceModel)
results = []
for process_instance in process_instance_sqlalchemy_rows:
process_instance_dict = process_instance["ProcessInstanceModel"].serialized
for metadata_column in metadata_columns:
if metadata_column["accessor"] not in stock_columns:
if metadata_column["accessor"] not in process_instance_dict:
process_instance_dict[
metadata_column["accessor"]
] = process_instance[metadata_column["accessor"]]