Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upcoming milestone logic change in the workplan dashboard #2337

Merged
merged 1 commit into from
Jun 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading