finished base for metadata reporting w/ burnettk
This commit is contained in:
parent
45eafc6060
commit
4d048d6e11
|
@ -940,19 +940,17 @@ def process_instance_list(
|
||||||
if column["accessor"] in stock_columns:
|
if column["accessor"] in stock_columns:
|
||||||
continue
|
continue
|
||||||
instance_metadata_alias = aliased(ProcessInstanceMetadataModel)
|
instance_metadata_alias = aliased(ProcessInstanceMetadataModel)
|
||||||
process_instance_query = (
|
process_instance_query = process_instance_query.outerjoin(
|
||||||
process_instance_query.outerjoin(
|
instance_metadata_alias,
|
||||||
instance_metadata_alias,
|
and_(
|
||||||
ProcessInstanceModel.id == instance_metadata_alias.process_instance_id,
|
ProcessInstanceModel.id == instance_metadata_alias.process_instance_id,
|
||||||
)
|
instance_metadata_alias.key == column["accessor"],
|
||||||
.filter(instance_metadata_alias.key == column["accessor"])
|
),
|
||||||
.add_columns(
|
).add_columns(func.max(instance_metadata_alias.value).label(column["accessor"]))
|
||||||
func.max(instance_metadata_alias.value).label(column["accessor"])
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
process_instances = (
|
process_instances = (
|
||||||
process_instance_query.group_by(ProcessInstanceModel.id)
|
process_instance_query.group_by(ProcessInstanceModel.id)
|
||||||
|
.add_columns(ProcessInstanceModel.id)
|
||||||
.order_by(
|
.order_by(
|
||||||
ProcessInstanceModel.start_in_seconds.desc(), ProcessInstanceModel.id.desc() # type: ignore
|
ProcessInstanceModel.start_in_seconds.desc(), ProcessInstanceModel.id.desc() # type: ignore
|
||||||
)
|
)
|
||||||
|
|
|
@ -5,7 +5,6 @@ from typing import Optional
|
||||||
import sqlalchemy
|
import sqlalchemy
|
||||||
from flask_bpmn.models.db import db
|
from flask_bpmn.models.db import db
|
||||||
|
|
||||||
from spiffworkflow_backend.models.process_instance import ProcessInstanceModel
|
|
||||||
from spiffworkflow_backend.models.process_instance_report import (
|
from spiffworkflow_backend.models.process_instance_report import (
|
||||||
ProcessInstanceReportModel,
|
ProcessInstanceReportModel,
|
||||||
)
|
)
|
||||||
|
@ -253,12 +252,11 @@ class ProcessInstanceReportService:
|
||||||
metadata_columns: list[dict],
|
metadata_columns: list[dict],
|
||||||
) -> list[dict]:
|
) -> list[dict]:
|
||||||
"""Add_metadata_columns_to_process_instance."""
|
"""Add_metadata_columns_to_process_instance."""
|
||||||
stock_columns = cls.get_column_names_for_model(ProcessInstanceModel)
|
|
||||||
results = []
|
results = []
|
||||||
for process_instance in process_instance_sqlalchemy_rows:
|
for process_instance in process_instance_sqlalchemy_rows:
|
||||||
process_instance_dict = process_instance["ProcessInstanceModel"].serialized
|
process_instance_dict = process_instance["ProcessInstanceModel"].serialized
|
||||||
for metadata_column in metadata_columns:
|
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[
|
process_instance_dict[
|
||||||
metadata_column["accessor"]
|
metadata_column["accessor"]
|
||||||
] = process_instance[metadata_column["accessor"]]
|
] = process_instance[metadata_column["accessor"]]
|
||||||
|
|
Loading…
Reference in New Issue