Support reporting on task data (#47)
This commit is contained in:
parent
68130b216d
commit
5786c8d83c
|
@ -811,18 +811,12 @@ def process_instance_list(
|
|||
ProcessInstanceModel.start_in_seconds.desc(), ProcessInstanceModel.id.desc() # type: ignore
|
||||
).paginate(page=page, per_page=per_page, error_out=False)
|
||||
|
||||
# TODO need to look into test failures when the results from result_dict is
|
||||
# used instead of the process instances
|
||||
|
||||
# substitution_variables = request.args.to_dict()
|
||||
# result_dict = process_instance_report.generate_report(
|
||||
# process_instances.items, substitution_variables
|
||||
# )
|
||||
|
||||
# results = result_dict["results"]
|
||||
# report_metadata = result_dict["report_metadata"]
|
||||
|
||||
results = process_instances.items
|
||||
results = list(
|
||||
map(
|
||||
ProcessInstanceService.serialize_flat_with_task_data,
|
||||
process_instances.items,
|
||||
)
|
||||
)
|
||||
report_metadata = process_instance_report.report_metadata
|
||||
|
||||
response_json = {
|
||||
|
|
|
@ -315,3 +315,22 @@ class ProcessInstanceService:
|
|||
)
|
||||
|
||||
return task
|
||||
|
||||
@staticmethod
|
||||
def serialize_flat_with_task_data(
|
||||
process_instance: ProcessInstanceModel,
|
||||
) -> dict[str, Any]:
|
||||
"""serialize_flat_with_task_data."""
|
||||
results = {}
|
||||
try:
|
||||
original_status = process_instance.status
|
||||
processor = ProcessInstanceProcessor(process_instance)
|
||||
process_instance.data = processor.get_current_data()
|
||||
results = process_instance.serialized_flat
|
||||
# this process seems to mutate the status of the process_instance which
|
||||
# can result in different results than expected from process_instance_list,
|
||||
# so set the status back to the expected value
|
||||
results["status"] = original_status
|
||||
except ApiError:
|
||||
results = process_instance.serialized
|
||||
return results
|
||||
|
|
Loading…
Reference in New Issue