From 059378675234bf73b8a8b19c0cd742a4598016f4 Mon Sep 17 00:00:00 2001 From: Dinesh <97143739+dinesh-aot@users.noreply.github.com> Date: Mon, 11 Dec 2023 12:09:23 -0800 Subject: [PATCH] Financial Events to be included (#1434) --- epictrack-api/src/api/models/event.py | 5 +++-- epictrack-api/src/api/models/event_category.py | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/epictrack-api/src/api/models/event.py b/epictrack-api/src/api/models/event.py index bbe6c90a7..a3471b5a4 100644 --- a/epictrack-api/src/api/models/event.py +++ b/epictrack-api/src/api/models/event.py @@ -16,7 +16,7 @@ from sqlalchemy import Boolean, Column, DateTime, ForeignKey, Integer, String, and_ from sqlalchemy.orm import relationship -from api.models.event_category import EventCategory +from api.models.event_category import EventCategory, PRIMARY_CATEGORIES from api.models.event_configuration import EventConfiguration from .base_model import BaseModelVersioned @@ -66,6 +66,7 @@ def find_by_work_id(cls, work_id: int): @classmethod def find_milestone_events_by_work_phase(cls, work_phase_id: int): """Return milestones by work id and phase id.""" + category_ids = list(map(lambda x: x.value, PRIMARY_CATEGORIES)) return ( Event.query.join( EventConfiguration, @@ -80,7 +81,7 @@ def find_milestone_events_by_work_phase(cls, work_phase_id: int): EventCategory, and_( EventConfiguration.event_category_id == EventCategory.id, - EventCategory.name.notin_(["Calendar", "Finance"]), + EventCategory.id.in_(category_ids), ), ) .all() diff --git a/epictrack-api/src/api/models/event_category.py b/epictrack-api/src/api/models/event_category.py index dc14a562c..01ef31992 100644 --- a/epictrack-api/src/api/models/event_category.py +++ b/epictrack-api/src/api/models/event_category.py @@ -46,4 +46,5 @@ class EventCategory(BaseModelVersioned): EventCategoryEnum.DECISION, EventCategoryEnum.EXTENSION, EventCategoryEnum.SUSPENSION, - EventCategoryEnum.PCP] + EventCategoryEnum.PCP, + EventCategoryEnum.FINANCE]