From b3fdb8b74629463347560290ad906bfa6d94f69c Mon Sep 17 00:00:00 2001 From: Shaelyn Tolkamp Date: Tue, 10 Dec 2024 14:57:33 -0800 Subject: [PATCH 1/2] [Track-309] AS transition orders --- epictrack-api/src/api/models/event_type.py | 9 +-- .../reports/anticipated_schedule_report.py | 59 ++++++++++--------- 2 files changed, 37 insertions(+), 31 deletions(-) diff --git a/epictrack-api/src/api/models/event_type.py b/epictrack-api/src/api/models/event_type.py index fe3504eb5..8758edfaf 100644 --- a/epictrack-api/src/api/models/event_type.py +++ b/epictrack-api/src/api/models/event_type.py @@ -25,11 +25,12 @@ class EventTypeEnum(enum.Enum): """Enum for event type""" # pylint: disable=C0103 - TIME_LIMIT_SUSPENSION = 12 - TIME_LIMIT_RESUMPTION = 38 - REFERRAL = 5 - MINISTER_DECISION = 14 + ADM = 16 CEAO_DECISION = 15 + MINISTER_DECISION = 14 + REFERRAL = 5 + TIME_LIMIT_RESUMPTION = 38 + TIME_LIMIT_SUSPENSION = 12 class EventType(BaseModelVersioned): diff --git a/epictrack-api/src/api/reports/anticipated_schedule_report.py b/epictrack-api/src/api/reports/anticipated_schedule_report.py index c6acbc414..0890377eb 100644 --- a/epictrack-api/src/api/reports/anticipated_schedule_report.py +++ b/epictrack-api/src/api/reports/anticipated_schedule_report.py @@ -12,6 +12,7 @@ from api.models.event import Event from api.models.event_category import EventCategoryEnum from api.models.event_configuration import EventConfiguration +from api.models.event_type import EventTypeEnum from api.models.federal_involvement import FederalInvolvement, FederalInvolvementEnum from api.models.work_issues import WorkIssues from api.models.work_issue_updates import WorkIssueUpdates @@ -188,48 +189,52 @@ def _fetch_data(self, report_date): or_( Event.event_configuration_id.in_( db.session.query(EventConfiguration.id).filter( - EventConfiguration.event_category_id == 1, # Milestone - EventConfiguration.event_type_id == 5 # EA Referral + EventConfiguration.event_category_id == EventCategoryEnum.MILESTONE.value, + EventConfiguration.event_type_id == EventTypeEnum.REFERRAL.value ) ), Event.event_configuration_id.in_( db.session.query(EventConfiguration.id).filter( - EventConfiguration.event_category_id == 4, # Decision - EventConfiguration.event_type_id == 14 # Minister + EventConfiguration.event_category_id == EventCategoryEnum.DECISION.value, + EventConfiguration.event_type_id == EventTypeEnum.MINISTER_DECISION.value ) ), and_( Event.is_active.is_(True), and_( Work.work_type_id == 5, # Exemption Order - Event.event_configuration_id.in_( - db.session.query(EventConfiguration.id).filter( - EventConfiguration.event_category_id == 4, # Decision - EventConfiguration.name != "IPD/EP Approval Decision (Day Zero)", - EventConfiguration.event_type_id == 15 # CEAO - ) + or_( + Event.event_configuration_id.in_( + db.session.query(EventConfiguration.id).filter( + EventConfiguration.event_category_id == EventCategoryEnum.DECISION.value, + EventConfiguration.name != "IPD/EP Approval Decision (Day Zero)", + EventConfiguration.event_type_id == EventTypeEnum.CEAO_DECISION.value + ) + ), ) ), and_( Work.work_type_id == 6, # Assessment - Event.event_configuration_id.in_( - db.session.query(EventConfiguration.id).filter( - EventConfiguration.event_category_id == 4, # Decision - EventConfiguration.name != "IPD/EP Approval Decision (Day Zero)", - EventConfiguration.name != "Revised EAC Application Acceptance Decision (Day Zero)", - EventConfiguration.event_type_id == 15 # CEAO - ) + or_( + Event.event_configuration_id.in_( + db.session.query(EventConfiguration.id).filter( + EventConfiguration.event_category_id == EventCategoryEnum.DECISION.value, + EventConfiguration.name != "IPD/EP Approval Decision (Day Zero)", + EventConfiguration.name != "Revised EAC Application Acceptance Decision (Day Zero)", + EventConfiguration.event_type_id == EventTypeEnum.CEAO_DECISION.value + ) + ), ) ), and_( Work.work_type_id == 7, # Ammendment Event.event_configuration_id.in_( db.session.query(EventConfiguration.id).filter( - EventConfiguration.event_category_id == 4, # Decision + EventConfiguration.event_category_id == EventCategoryEnum.DECISION.value, EventConfiguration.name != "Delegation of Amendment Decision", or_( - EventConfiguration.event_type_id == 15, # CEAO - EventConfiguration.event_type_id == 16 # ADM + EventConfiguration.event_type_id == EventTypeEnum.CEAO_DECISION.value, + EventConfiguration.event_type_id == EventTypeEnum.ADM.value ) ) ) @@ -238,8 +243,8 @@ def _fetch_data(self, report_date): Work.work_type_id == 9, # EAC Extension Event.event_configuration_id.in_( db.session.query(EventConfiguration.id).filter( - EventConfiguration.event_category_id == 4, # Decision - EventConfiguration.event_type_id == 15 # CEAO + EventConfiguration.event_category_id == EventCategoryEnum.DECISION.value, + EventConfiguration.event_type_id == EventTypeEnum.ADM.value ) ) ), @@ -247,9 +252,9 @@ def _fetch_data(self, report_date): Work.work_type_id == 10, # Substantial Start Decision Event.event_configuration_id.in_( db.session.query(EventConfiguration.id).filter( - EventConfiguration.event_category_id == 4, # Decision + EventConfiguration.event_category_id == EventCategoryEnum.DECISION.value, EventConfiguration.name != "Delegation of SubStart Decision to Minister", - EventConfiguration.event_type_id == 15 # CEAO + EventConfiguration.event_type_id == EventTypeEnum.ADM.value ) ) ), @@ -257,11 +262,11 @@ def _fetch_data(self, report_date): Work.work_type_id == 11, # EAC/Order Transfer Event.event_configuration_id.in_( db.session.query(EventConfiguration.id).filter( - EventConfiguration.event_category_id == 4, # Decision + EventConfiguration.event_category_id == EventCategoryEnum.DECISION.value, EventConfiguration.name != "Delegation of Transfer Decision to Minister", or_( - EventConfiguration.event_type_id == 15, # CEAO - EventConfiguration.event_type_id == 16 # ADM + EventConfiguration.event_type_id == EventTypeEnum.CEAO_DECISION.value + EventConfiguration.event_type_id == EventTypeEnum.ADM.value ) ) ) From a531cae7180ff5a745a0e88dbfc9db993c157ff4 Mon Sep 17 00:00:00 2001 From: Shaelyn Tolkamp Date: Tue, 10 Dec 2024 15:00:15 -0800 Subject: [PATCH 2/2] remove hanging or_ --- .../reports/anticipated_schedule_report.py | 33 ++++++++----------- 1 file changed, 14 insertions(+), 19 deletions(-) diff --git a/epictrack-api/src/api/reports/anticipated_schedule_report.py b/epictrack-api/src/api/reports/anticipated_schedule_report.py index 0890377eb..494077604 100644 --- a/epictrack-api/src/api/reports/anticipated_schedule_report.py +++ b/epictrack-api/src/api/reports/anticipated_schedule_report.py @@ -17,7 +17,6 @@ from api.models.work_issues import WorkIssues from api.models.work_issue_updates import WorkIssueUpdates from api.models.work_type import WorkType, WorkTypeEnum -from api.models.event_type import EventTypeEnum from api.models.ministry import Ministry from api.models.phase_code import PhaseCode from api.models.project import Project @@ -203,27 +202,23 @@ def _fetch_data(self, report_date): Event.is_active.is_(True), and_( Work.work_type_id == 5, # Exemption Order - or_( - Event.event_configuration_id.in_( - db.session.query(EventConfiguration.id).filter( - EventConfiguration.event_category_id == EventCategoryEnum.DECISION.value, - EventConfiguration.name != "IPD/EP Approval Decision (Day Zero)", - EventConfiguration.event_type_id == EventTypeEnum.CEAO_DECISION.value - ) - ), + Event.event_configuration_id.in_( + db.session.query(EventConfiguration.id).filter( + EventConfiguration.event_category_id == EventCategoryEnum.DECISION.value, + EventConfiguration.name != "IPD/EP Approval Decision (Day Zero)", + EventConfiguration.event_type_id == EventTypeEnum.CEAO_DECISION.value + ) ) ), and_( Work.work_type_id == 6, # Assessment - or_( - Event.event_configuration_id.in_( - db.session.query(EventConfiguration.id).filter( - EventConfiguration.event_category_id == EventCategoryEnum.DECISION.value, - EventConfiguration.name != "IPD/EP Approval Decision (Day Zero)", - EventConfiguration.name != "Revised EAC Application Acceptance Decision (Day Zero)", - EventConfiguration.event_type_id == EventTypeEnum.CEAO_DECISION.value - ) - ), + Event.event_configuration_id.in_( + db.session.query(EventConfiguration.id).filter( + EventConfiguration.event_category_id == EventCategoryEnum.DECISION.value, + EventConfiguration.name != "IPD/EP Approval Decision (Day Zero)", + EventConfiguration.name != "Revised EAC Application Acceptance Decision (Day Zero)", + EventConfiguration.event_type_id == EventTypeEnum.CEAO_DECISION.value + ) ) ), and_( @@ -265,7 +260,7 @@ def _fetch_data(self, report_date): EventConfiguration.event_category_id == EventCategoryEnum.DECISION.value, EventConfiguration.name != "Delegation of Transfer Decision to Minister", or_( - EventConfiguration.event_type_id == EventTypeEnum.CEAO_DECISION.value + EventConfiguration.event_type_id == EventTypeEnum.CEAO_DECISION.value, EventConfiguration.event_type_id == EventTypeEnum.ADM.value ) )