From f000195786ca9a5aef48dfe96e9249e4a37bc28f Mon Sep 17 00:00:00 2001 From: jasquat Date: Mon, 29 Aug 2022 10:44:04 -0400 Subject: [PATCH] avoid sorting by display_order --- bin/import_tickets_for_script_task.py | 4 +++- src/spiffworkflow_backend/models/process_group.py | 2 +- src/spiffworkflow_backend/models/process_model.py | 2 +- src/spiffworkflow_backend/routes/process_api_blueprint.py | 4 ++-- src/spiffworkflow_backend/services/process_model_service.py | 1 + 5 files changed, 8 insertions(+), 5 deletions(-) diff --git a/bin/import_tickets_for_script_task.py b/bin/import_tickets_for_script_task.py index 3497216d..f747c5f7 100644 --- a/bin/import_tickets_for_script_task.py +++ b/bin/import_tickets_for_script_task.py @@ -15,7 +15,9 @@ def main(): from spiffworkflow_backend.services.process_instance_service import ( ProcessInstanceService, ) - from spiffworkflow_backend.models.process_instance_report import ProcessInstanceReportModel + from spiffworkflow_backend.models.process_instance_report import ( + ProcessInstanceReportModel, + ) process_model_identifier_ticket = "ticket" db.session.query(ProcessInstanceModel).filter( diff --git a/src/spiffworkflow_backend/models/process_group.py b/src/spiffworkflow_backend/models/process_group.py index 512bb402..0b100ed4 100644 --- a/src/spiffworkflow_backend/models/process_group.py +++ b/src/spiffworkflow_backend/models/process_group.py @@ -28,7 +28,7 @@ class ProcessGroup: def __post_init__(self) -> None: """__post_init__.""" - self.sort_index = f"{self.display_order}:{self.id}" + self.sort_index = self.id def __eq__(self, other: Any) -> bool: """__eq__.""" diff --git a/src/spiffworkflow_backend/models/process_model.py b/src/spiffworkflow_backend/models/process_model.py index d39527d0..d3e2d1ef 100644 --- a/src/spiffworkflow_backend/models/process_model.py +++ b/src/spiffworkflow_backend/models/process_model.py @@ -45,7 +45,7 @@ class ProcessModelInfo: def __post_init__(self) -> None: """__post_init__.""" - self.sort_index = f"{self.display_order}:{self.process_group_id}:{self.id}" + self.sort_index = f"{self.process_group_id}:{self.id}" def __eq__(self, other: Any) -> bool: """__eq__.""" diff --git a/src/spiffworkflow_backend/routes/process_api_blueprint.py b/src/spiffworkflow_backend/routes/process_api_blueprint.py index 55ecf70e..dfbae244 100644 --- a/src/spiffworkflow_backend/routes/process_api_blueprint.py +++ b/src/spiffworkflow_backend/routes/process_api_blueprint.py @@ -92,7 +92,7 @@ def process_group_update( def process_groups_list(page: int = 1, per_page: int = 100) -> flask.wrappers.Response: """Process_groups_list.""" - process_groups = sorted(ProcessModelService().get_process_groups()) + process_groups = ProcessModelService().get_process_groups() batch = ProcessModelService().get_batch( items=process_groups, page=page, per_page=per_page ) @@ -195,7 +195,7 @@ def process_model_list( process_group_id: str, page: int = 1, per_page: int = 100 ) -> flask.wrappers.Response: """Process model list!""" - process_models = sorted(ProcessModelService().get_process_models(process_group_id)) + process_models = ProcessModelService().get_process_models(process_group_id) batch = ProcessModelService().get_batch( process_models, page=page, per_page=per_page ) diff --git a/src/spiffworkflow_backend/services/process_model_service.py b/src/spiffworkflow_backend/services/process_model_service.py index 5339ab9b..cc98cb0d 100644 --- a/src/spiffworkflow_backend/services/process_model_service.py +++ b/src/spiffworkflow_backend/services/process_model_service.py @@ -156,6 +156,7 @@ class ProcessModelService(FileSystemService): process_models = [] for process_group in process_groups: process_models.extend(process_group.process_models) + process_models.sort() return process_models def get_process_groups(self) -> list[ProcessGroup]: