From 03068f9ad4cc4f58d7fd38c576d4a21970c25f23 Mon Sep 17 00:00:00 2001 From: Shaelyn Tolkamp <46355612+tolkamps1@users.noreply.github.com> Date: Thu, 5 Dec 2024 08:10:37 -0800 Subject: [PATCH] [Track-276] AS add responsible minister or responsible ministry (#2466) --- .../reports/anticipated_schedule_report.py | 31 ++++++++++++++++-- .../anticipated_schedule.docx | Bin 15997 -> 16068 bytes .../eaReferral/AnticipatedEAOSchedule.tsx | 31 +++++++++++++----- 3 files changed, 52 insertions(+), 10 deletions(-) diff --git a/epictrack-api/src/api/reports/anticipated_schedule_report.py b/epictrack-api/src/api/reports/anticipated_schedule_report.py index f0116394d..3e327a819 100644 --- a/epictrack-api/src/api/reports/anticipated_schedule_report.py +++ b/epictrack-api/src/api/reports/anticipated_schedule_report.py @@ -60,7 +60,8 @@ def __init__(self, filters, color_intensity): "report_description", "anticipated_decision_date", "additional_info", - "ministry_name", + "responsible_minister", + "ministry", "referral_date", "eac_decision_by", "decision_by", @@ -86,6 +87,7 @@ def _fetch_data(self, report_date): start_date = report_date + timedelta(days=-7) report_date = report_date.astimezone(timezone('US/Pacific')) staff_decision_by = aliased(Staff) + staff_minister = aliased(Staff) next_pecp_query = self._get_next_pcp_query(start_date) referral_event_query = self._get_referral_event_query(start_date) @@ -95,6 +97,7 @@ def _fetch_data(self, report_date): exclude_phase_names = self.filters["exclude"] formatted_phase_name = self._get_formatted_phase_name() ea_type_column = self._get_ea_type_column(formatted_phase_name) + responsible_minister_column = self._get_responsible_minister_column(staff_minister) current_app.logger.debug(f"Executing query for {self.report_title} report") results_qry = ( @@ -128,6 +131,7 @@ def _fetch_data(self, report_date): .join(Region, Region.id == Project.region_id_env) .join(EAAct, EAAct.id == Work.ea_act_id) .join(Ministry) + .outerjoin(staff_minister, Ministry.minister_id == staff_minister.id) .outerjoin(latest_status_updates, latest_status_updates.c.work_id == Work.id) .outerjoin( staff_decision_by, # Join staff alias @@ -274,7 +278,14 @@ def _fetch_data(self, report_date): Event.anticipated_date + func.cast(func.concat(Event.number_of_days, " DAYS"), INTERVAL) ).label("anticipated_decision_date"), latest_status_updates.c.description.label("additional_info"), - Ministry.name.label("ministry_name"), + case( + ( + Ministry.name != "Not Applicable", + Ministry.name + ), + else_="" + ).label("ministry"), + responsible_minister_column, ( Event.anticipated_date + func.cast(func.concat(Event.number_of_days, " DAYS"), INTERVAL) ).label("referral_date"), @@ -431,6 +442,22 @@ def _get_formatted_phase_name(self): else_=func.concat(func.substring(PhaseCode.name, r"\((.*?)\)"), " Amendment"), ).label("formatted_phase_name") + def _get_responsible_minister_column(self, staff_minister): + """Returns an expression for the responsible minister""" + return case( + ( + Ministry.name != "Not Applicable", + case( + ( + func.concat(staff_minister.first_name, staff_minister.last_name) != "", + func.concat(staff_minister.first_name, " ", staff_minister.last_name) + ), + else_="" + ) + ), + else_=None, + ).label("responsible_minister") + def _get_next_pcp_query(self, start_date): """Create and return the subquery for next PCP event based on start date""" pecp_configuration_ids = ( diff --git a/epictrack-api/src/api/reports/report_templates/anticipated_schedule.docx b/epictrack-api/src/api/reports/report_templates/anticipated_schedule.docx index 25609c891a813fc4995f6e5a9c0d63cddad7da4f..8c74d711333065e4aae1c1d92833f92bbd53097d 100644 GIT binary patch delta 4453 zcmZ8lXFQzC9^OTi=)J|VI#E|=308^T5-c0N_YwqItEb>7tBWrB>OIj3OCq905G4`4 zi$n>o$T|0S?wt?sZ=Qdhd1gM$^PWHMLz3!i;o{K%2nh)RB>9nvq?{-Ny$BJCke? zDEDhGGK_^~nVGz8yGM^Q6}{-c*+mI9LWJ4N)RQ!acQDa@(15HK7R{{JQ4h*QQ}HKE zEs7BCXSgbvtZYP(wOSeXfM^jf$rc9{7(}VEiit8?3foR#znUJK`57a@v-iCf;XX`} zKBRAzcVvJw&CCfOkC(jL72zrc(>&CD&EY5{VzW~9{j(Tf5d^XQ zXVTz3_3m$6=>8EwDDHY^rRbD7E=!XRUU;er%? z*p7Osl($)FEj-hirc+q8nci%h^?88DYc`mPn%>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+Y04Qd5o`<1 zWQUKmuVuZVQ@8$oS$VZ*FQ^7!tWcNTF-^yl#$p(Qh zZMJwvr#3lBW@TeIoc;%12`saB$zl1)oQmlFfh3EyRR+yBt6L+23Sq|6)Mr3mLX#py z@@@I=n-Y8}FPnno0^wNLZ4{RYH*M)c$i3WZNvk0}3W-F1OArvNCpPFB&qVe{RLMGO zp1Za?=I7a>qT{o_Wx-^{OV)XM06?t%Kl18S761bXG1Ba1-OM^7G9?aQT?+4DXS5uIdwl#5bR|WlBIuiMU1rIACPKU?4OlOunT{b2I|u8 zX|SH$*l8LGdB#5;R}{VjX;1PQo$5b=f|4BfZ|iRr!wC3$WD_ElxKFX(Dscfh2%SoN zr`Gz3HBVqr7CVjq`?yShhXbwIlWaPs__ z&;#c=#TnmEn_2#UaS((vh(Gj6Be;MzgqsN7Q!-o;Tx2s)LL`Fo)XY8EBqO{>NbvmT zrZ?wJQ_4xnTPF|8ze+#6L@<|Q6aQ~MWQU%}be%Y=pVR>USHP$o0WN=z;H<)Mn#V_l Vi)=-npsT<}C{kghno#`h{69=^0mlFU diff --git a/epictrack-web/src/components/reports/eaReferral/AnticipatedEAOSchedule.tsx b/epictrack-web/src/components/reports/eaReferral/AnticipatedEAOSchedule.tsx index f20f4577c..f50f912fa 100644 --- a/epictrack-web/src/components/reports/eaReferral/AnticipatedEAOSchedule.tsx +++ b/epictrack-web/src/components/reports/eaReferral/AnticipatedEAOSchedule.tsx @@ -293,14 +293,29 @@ export default function AnticipatedEAOSchedule() { EA Type {item["ea_type"]} - - - Responsible Minister - - - {item["ministry_name"]} - - + {item["ministry"] && ( + + {item["responsible_minister"] ? ( + <> + + Responsible Minister + + + {item["responsible_minister"]} + + + ) : ( + <> + + Responsible Ministry + + + {item["ministry"]} + + + )} + + )} Decision to be made by