Skip to content

Commit 28512da

Browse files
committed
[Track-220] Update Anticipated Date label
1 parent a44119f commit 28512da

File tree

2 files changed

+39
-11
lines changed

2 files changed

+39
-11
lines changed

epictrack-api/src/api/reports/anticipated_schedule_report.py

Lines changed: 39 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ def __init__(self, filters, color_intensity):
4747
"work_id",
4848
"event_id",
4949
"work_issues",
50-
"phase_name",
5150
"date_updated",
5251
"project_name",
5352
"proponent",
@@ -64,7 +63,7 @@ def __init__(self, filters, color_intensity):
6463
"ministry",
6564
"referral_date",
6665
"actual_date",
67-
"eac_decision_by",
66+
"anticipated_date_label",
6867
"decision_by",
6968
"next_pecp_date",
7069
"next_pecp_title",
@@ -123,6 +122,8 @@ def _fetch_data(self, report_date):
123122
exclude_phase_names = self.filters["exclude"]
124123
formatted_phase_name = self._get_formatted_phase_name()
125124
formatted_work_type = self._get_formatted_work_type_name()
125+
formatted_anticipated_date = self._get_formatted_date_label(formatted_work_type, formatted_phase_name)
126+
anticipated_date_column = self._get_anticipated_date_column(formatted_anticipated_date)
126127
ea_type_column = self._get_ea_type_column(formatted_phase_name)
127128
responsible_minister_column = self._get_responsible_minister_column(staff_minister)
128129

@@ -292,7 +293,7 @@ def _fetch_data(self, report_date):
292293
else_=Project.name
293294
).label("amendment_title"),
294295
ea_type_column,
295-
formatted_phase_name.label("phase_name"),
296+
anticipated_date_column.label("anticipated_date_label"),
296297
latest_status_updates.c.posted_date.label("date_updated"),
297298
Project.name.label("project_name"),
298299
func.coalesce(
@@ -320,14 +321,6 @@ def _fetch_data(self, report_date):
320321
Event.anticipated_date + func.cast(func.concat(Event.number_of_days, " DAYS"), INTERVAL)
321322
).label("referral_date"),
322323
Event.actual_date.label("actual_date"),
323-
case(
324-
(
325-
EventConfiguration.event_type_id == EventTypeEnum.MINISTER_DECISION.value,
326-
func.concat(Staff.first_name, " ", Staff.last_name)
327-
),
328-
else_="",
329-
).label("eac_decision_by"),
330-
staff_decision_by.first_name.label("eac_decision_by"),
331324
case(
332325
(
333326
EventConfiguration.event_type_id != EventTypeEnum.MINISTER_DECISION.value,
@@ -475,6 +468,41 @@ def _get_ea_type_column(self, formatted_phase_name):
475468
else_=WorkType.name,
476469
).label("ea_type")
477470

471+
def _get_formatted_date_label(self, formatted_work_type, formatted_phase_name):
472+
"""Returns an expression for the date label"""
473+
return case(
474+
(
475+
EventConfiguration.event_type_id == EventTypeEnum.REFERRAL.value,
476+
case(
477+
(
478+
PhaseCode.name == "Effects Assessment & Recommendation",
479+
"EA Certificate Package",
480+
),
481+
else_=formatted_phase_name,
482+
)
483+
),
484+
else_=case(
485+
(
486+
EventConfiguration.event_type_id == EventTypeEnum.MINISTER_DECISION.value,
487+
"EA Certificate"
488+
),
489+
else_=formatted_work_type,
490+
)
491+
)
492+
493+
def _get_anticipated_date_column(self, formatted_anticipated_date):
494+
"""Returns an expression for the anticipated date"""
495+
referral_postfix = " Referral Date"
496+
decision_postfix = " Decision Date"
497+
date_prefix = "Anticipated "
498+
return case(
499+
(
500+
EventConfiguration.event_type_id == EventTypeEnum.REFERRAL.value,
501+
func.concat(date_prefix, formatted_anticipated_date, referral_postfix)
502+
),
503+
else_=func.concat(date_prefix, formatted_anticipated_date, decision_postfix),
504+
).label("anticipated_date_label")
505+
478506
def _get_formatted_phase_name(self):
479507
"""Returns an expression for the reformatted PhaseCode.name"""
480508
return case(
Binary file not shown.

0 commit comments

Comments
 (0)