From bf2824cf8dd9c1a7d2b24e120c743c7ec2b60e85 Mon Sep 17 00:00:00 2001 From: Marc Vilanova <39573146+mvilanova@users.noreply.github.com> Date: Wed, 7 Dec 2022 09:15:20 -0800 Subject: [PATCH] Returns incident types ordered by name and severities and priorities ordered by viewing order (#2750) * Returns incident types ordered by name * Returns incident severities ordered by view order * Returns incident priorities ordered by view order --- src/dispatch/incident/priority/service.py | 7 ++++++- src/dispatch/incident/severity/service.py | 7 ++++++- src/dispatch/incident/type/service.py | 7 ++++++- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/dispatch/incident/priority/service.py b/src/dispatch/incident/priority/service.py index aaf2a2270a17..8d8b89467387 100644 --- a/src/dispatch/incident/priority/service.py +++ b/src/dispatch/incident/priority/service.py @@ -113,8 +113,13 @@ def get_all_enabled(*, db_session, project_id: int = None) -> List[Optional[Inci db_session.query(IncidentPriority) .filter(IncidentPriority.project_id == project_id) .filter(IncidentPriority.enabled == true()) + .order_by(IncidentPriority.view_order) ) - return db_session.query(IncidentPriority).filter(IncidentPriority.enabled == true()) + return ( + db_session.query(IncidentPriority) + .filter(IncidentPriority.enabled == true()) + .order_by(IncidentPriority.view_order) + ) def create(*, db_session, incident_priority_in: IncidentPriorityCreate) -> IncidentPriority: diff --git a/src/dispatch/incident/severity/service.py b/src/dispatch/incident/severity/service.py index 01eaea8bf18d..1ee317e4d0bd 100644 --- a/src/dispatch/incident/severity/service.py +++ b/src/dispatch/incident/severity/service.py @@ -116,9 +116,14 @@ def get_all_enabled(*, db_session, project_id: int = None) -> List[Optional[Inci db_session.query(IncidentSeverity) .filter(IncidentSeverity.project_id == project_id) .filter(IncidentSeverity.enabled == true()) + .order_by(IncidentSeverity.view_order) ) - return db_session.query(IncidentSeverity).filter(IncidentSeverity.enabled == true()) + return ( + db_session.query(IncidentSeverity) + .filter(IncidentSeverity.enabled == true()) + .order_by(IncidentSeverity.view_order) + ) def create(*, db_session, incident_severity_in: IncidentSeverityCreate) -> IncidentSeverity: diff --git a/src/dispatch/incident/type/service.py b/src/dispatch/incident/type/service.py index 052cfbfd37e0..98248da00918 100644 --- a/src/dispatch/incident/type/service.py +++ b/src/dispatch/incident/type/service.py @@ -112,8 +112,13 @@ def get_all_enabled(*, db_session, project_id: int = None) -> List[Optional[Inci db_session.query(IncidentType) .filter(IncidentType.project_id == project_id) .filter(IncidentType.enabled == true()) + .order_by(IncidentType.name) ) - return db_session.query(IncidentType).filter(IncidentType.enabled == true()) + return ( + db_session.query(IncidentType) + .filter(IncidentType.enabled == true()) + .order_by(IncidentType.name) + ) def create(*, db_session, incident_type_in: IncidentTypeCreate) -> IncidentType: