Skip to content

Commit

Permalink
Upcoming milestone logic change in the workplan dashboard (#2337)
Browse files Browse the repository at this point in the history
  • Loading branch information
dinesh-aot authored Jun 19, 2024
1 parent 4e1d7b5 commit 77fe204
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions epictrack-api/src/api/services/work_phase.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
from api.models.event_category import EventCategoryEnum
from api.schemas.work_v2 import WorkPhaseSchema
from api.models.phase_code import PhaseVisibilityEnum
from api.models.event_template import EventPositionEnum
from api.services.event import EventService
from api.services.task_template import TaskTemplateService
from .common_service import event_compare_func
Expand Down Expand Up @@ -195,9 +196,23 @@ def _get_milestone_information(cls, work_phase_events):
remaining_milestone_events = [
event for event in work_phase_events if event.actual_date is None
]
result["next_milestone"] = (
remaining_milestone_events[0].name if remaining_milestone_events else None
next_milestone = (
remaining_milestone_events[0] if remaining_milestone_events else None
)
end_milestone = next(
(
event
for event in remaining_milestone_events
if event.event_position == EventPositionEnum.END.value
),
None,
)
if next_milestone and end_milestone and next_milestone.id == end_milestone.id:
if end_milestone.id == remaining_milestone_events[-1].id:
next_milestone = end_milestone
else:
next_milestone = remaining_milestone_events[0]
result["next_milestone"] = next_milestone.name if next_milestone else None
result["next_milestone_date"] = (
remaining_milestone_events[0].anticipated_date
if remaining_milestone_events
Expand Down

0 comments on commit 77fe204

Please sign in to comment.