From 053f64c48bc8f4b71f4a1714d775a484a257cfbb Mon Sep 17 00:00:00 2001 From: Shaelyn Tolkamp <46355612+tolkamps1@users.noreply.github.com> Date: Tue, 10 Dec 2024 13:19:06 -0800 Subject: [PATCH] [Track-277] AS Sort groups in report (#2472) --- .../reports/anticipated_schedule_report.py | 68 ++++++++++++++---- .../src/api/reports/report_factory.py | 2 + .../anticipated_schedule.docx | Bin 16173 -> 16205 bytes .../api/reports/resource_forecast_report.py | 4 +- .../api/reports/thirty_sixty_ninety_report.py | 6 +- .../eaReferral/AnticipatedEAOSchedule.tsx | 59 ++++++++------- 6 files changed, 91 insertions(+), 48 deletions(-) diff --git a/epictrack-api/src/api/reports/anticipated_schedule_report.py b/epictrack-api/src/api/reports/anticipated_schedule_report.py index 6e2c9dfa..c6acbc41 100644 --- a/epictrack-api/src/api/reports/anticipated_schedule_report.py +++ b/epictrack-api/src/api/reports/anticipated_schedule_report.py @@ -74,14 +74,31 @@ def __init__(self, filters, color_intensity): "notes", "next_pecp_number_of_days", "amendment_title", - "work_type_id" + "work_type_id", + "work_type" + ] + group_by = "work_type" + group_order = [ + "Assessment", + "Typical Amendment", + "Complex Amendment", + "Simple Amendment", + "32(5) Amendment", + "Exemption Order", + "Project Notification", + "Minister's Designation", + "CEAO's Designation", + "EAC Extension", + "EAC/Order Transfer", + "Substantial Start Decision", + "EAC/Order Cancellation", ] - group_by = "phase_name" item_sort_key = "referral_date" template_name = "anticipated_schedule.docx" super().__init__( data_keys=data_keys, group_by=group_by, + group_sort_order=group_order, item_sort_key=item_sort_key, template_name=template_name, filters=filters, @@ -104,6 +121,7 @@ def _fetch_data(self, report_date): if self.filters and "exclude" in self.filters: exclude_phase_names = self.filters["exclude"] formatted_phase_name = self._get_formatted_phase_name() + formatted_work_type = self._get_formatted_work_type_name() ea_type_column = self._get_ea_type_column(formatted_phase_name) responsible_minister_column = self._get_responsible_minister_column(staff_minister) @@ -259,6 +277,7 @@ def _fetch_data(self, report_date): Event.id.label("event_id"), Work.id.label("work_id"), Work.work_type_id.label("work_type_id"), + formatted_work_type.label("work_type"), case( ( and_( @@ -270,7 +289,7 @@ def _fetch_data(self, report_date): else_=Project.name ).label("amendment_title"), ea_type_column, - PhaseCode.name.label("phase_name"), + formatted_phase_name.label("phase_name"), latest_status_updates.c.posted_date.label("date_updated"), Project.name.label("project_name"), func.coalesce( @@ -442,14 +461,37 @@ def _get_ea_type_column(self, formatted_phase_name): def _get_formatted_phase_name(self): """Returns an expression for the reformatted PhaseCode.name""" return case( - # Case for 32.5 - ( - func.substring(PhaseCode.name, r"\((.*?)\)") == "32.5", - "32(5) Amendment" - ), - else_=func.concat(func.substring(PhaseCode.name, r"\((.*?)\)"), " Amendment"), + ( + WorkType.id == WorkTypeEnum.AMENDMENT.value, + case( + # Case for 32.5 + ( + func.substring(PhaseCode.name, r"\((.*?)\)") == "32.5", + "32(5) Amendment" + ), + else_=func.concat(func.substring(PhaseCode.name, r"\((.*?)\)"), " Amendment"), + ) + ), + else_=PhaseCode.name ).label("formatted_phase_name") + def _get_formatted_work_type_name(self): + """Returns an expression for the reformatted workType.name""" + return case( + ( + WorkType.id == WorkTypeEnum.AMENDMENT.value, + case( + # Case for 32.5 + ( + func.substring(PhaseCode.name, r"\((.*?)\)") == "32.5", + "32(5) Amendment" + ), + else_=func.concat(func.substring(PhaseCode.name, r"\((.*?)\)"), " Amendment"), + ) + ), + else_=WorkType.name + ).label("formatted_work_type") + def _get_responsible_minister_column(self, staff_minister): """Returns an expression for the responsible minister""" return case( @@ -531,12 +573,12 @@ def _get_referral_event_query(self, start_date): .subquery() ) - def _update_staleness(self, data: dict, report_date: datetime) -> dict: + def _update_staleness(self, data: list, report_date: datetime) -> list: """Calculate the staleness based on report date""" date = report_date.astimezone(CANADA_TIMEZONE) - for _, work_type_data in data.items(): - for work in work_type_data: - if work["date_updated"]: + for group in data: + for work in group.get("items"): + if work.get("date_updated"): diff = (date - work["date_updated"]).days if diff > 10: work["staleness"] = StalenessEnum.CRITICAL.value diff --git a/epictrack-api/src/api/reports/report_factory.py b/epictrack-api/src/api/reports/report_factory.py index 25602cce..93f25872 100644 --- a/epictrack-api/src/api/reports/report_factory.py +++ b/epictrack-api/src/api/reports/report_factory.py @@ -88,6 +88,8 @@ def _format_data(self, data, report_title=None): else len(self.group_sort_order), # Move other groups last ) ) + formatted_data = [{"group": group, "items": items} for group, items in formatted_data.items()] + return formatted_data def _deserialize_work_issues(self, work_issues): 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 3273b927c7ea63eaad771da121a7c03d6eb60e7d..3c3ffcf9b1d36655b335f5112bf858834db74579 100644 GIT binary patch delta 4504 zcmY+HWk6I-+sBs<0atQK>0TsPiKR;#B&54Rsa1MuNr@$w4(VQ{5hP?u0coU5rA1PN z2l0OI=XuYEbLM~5%v^Im%&#hNIFMLN6$_gjfRB$4IL?kvBxZ%1YIgCH2b>!42HbbW zD}c-^PaLpD5eU&NIlT=2J|*I6d9c3=foMfNKmFqAyJxUA`<^$19>l|w!YIbf31BNX zDTjra)%$qIU~V@J_-Jz}k7Dp5-x$=5s_Ek9sK5E}hyZe+I3So$_SRiPD7I=wx_=kV zlgwd|!qt2+CijfLL$SETl^DS}} zF%`_U+lvSGEarV9?$E@!+b`4J=mDI9LCgE9CQdaE=T{wPU(={eR;mD0)~s37K+7aQ zI%#XGO+K}~zR!RXRbe5GlM^K9e^hv{@MUbmDd^gF3G@Q)ZaW?U#kjv^5uP}APWxg# zKCBPNV7toPn~>YzupxFiX=xI~Jwm5fu^R*H(Oqh_XpVJmW3(2=< zImUIh#S)*rZ1?hA(5H9%+^`VnAL6#4hILSfs1D*=cm)9zGI>q{JBm0QiCl z0Q@-%f`1PK(TE`cr_osl9V?-zQ%7 z-}4`x(zQvoW5r;p8ZRzGEBzJ(KPJ@zv57h7G27$Y^gf^YXpF}o62?lZR;nEHH8mM` zR`!7`jVoDp`*C|GXMo&pU=5puvCr2JjM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g&Q^=W(Y|0|2jk{^H+%xkU|ROMJmC6-!q4f38EYrm_!o85K+ISvX}Z6K)MW!Ntk^CH z*I)ON+|fmmS^2q(shSn&|3(lLw}~jv=QR0)r)ZqA!iD$)S?Dum`HLJy75K$7P(_RO zPvn1hf*w_ozVgT9dx&SfdJbfh|cAnPL^|$ List[WorkIssues]: """Combine the result with work issues""" - work_ids = set((work["work_id"] for work in data)) + work_ids = set((work.get("work_id") for work in data)) work_issues = WorkIssuesService.find_work_issues_by_work_ids(work_ids) for result_item in data: issue_per_work = [ issue for issue in work_issues - if issue.work_id == result_item["work_id"] + if issue.work_id == result_item.get("work_id") and issue.is_high_priority is True ] for issue in issue_per_work: @@ -233,7 +233,7 @@ def _update_work_issues(self, data) -> List[WorkIssues]: issue_per_work ) dates = [parser.isoparse(issue["latest_update"]["posted_date"]) for issue in issues] - dates.append(result_item["status_date_updated"]) + dates.append(result_item.get("status_date_updated")) if len(dates): result_item["oldest_update"] = min(dates) diff --git a/epictrack-web/src/components/reports/eaReferral/AnticipatedEAOSchedule.tsx b/epictrack-web/src/components/reports/eaReferral/AnticipatedEAOSchedule.tsx index f50f912f..8422c413 100644 --- a/epictrack-web/src/components/reports/eaReferral/AnticipatedEAOSchedule.tsx +++ b/epictrack-web/src/components/reports/eaReferral/AnticipatedEAOSchedule.tsx @@ -33,8 +33,17 @@ import ReportHeader from "../shared/report-header/ReportHeader"; import { ETPageContainer } from "../../shared"; import { staleLevel } from "utils/uiUtils"; +interface Group { + group: string; + items: any[]; +} + +interface ReportData { + data: Group[]; +} + export default function AnticipatedEAOSchedule() { - const [reports, setReports] = React.useState({}); + const [reports, setReports] = React.useState([]); const [showReportDateBanner, setShowReportDateBanner] = React.useState(false); const [selectedTab, setSelectedTab] = React.useState(0); @@ -54,10 +63,10 @@ export default function AnticipatedEAOSchedule() { }, [reportDate]); React.useEffect(() => { - const filterTypes = Object.keys(reports).filter( - (ele, index, arr) => arr.findIndex((t) => t === ele) === index - ); - setTypeFilter(filterTypes); + if (reports) { + const filterTypes: string[] = reports.map((report) => report.group); + setTypeFilter(filterTypes); + } }, [reports]); const fetchReportData = React.useCallback(async () => { setResultStatus(RESULT_STATUS.LOADING); @@ -70,7 +79,8 @@ export default function AnticipatedEAOSchedule() { ); setResultStatus(RESULT_STATUS.LOADED); if (reportData.status === 200) { - setReports((reportData.data as never)["data"]); + const reports = reportData.data as ReportData; + setReports(reports.data); } if (reportData.status === 204) { @@ -117,25 +127,6 @@ export default function AnticipatedEAOSchedule() { setSelectedTab(newValue); }; - // const staleLevel = React.useCallback( - // (staleness: string) => { - // if (staleness == StalenessEnum.CRITICAL) { - // return { - // background: Palette.error.main, - // }; - // } else if (staleness == StalenessEnum.WARN) { - // return { - // background: Palette.secondary.main, - // }; - // } else { - // return { - // background: Palette.success.main, - // }; - // } - // }, - // [reportDate] - // ); - interface TabPanelProps { children?: React.ReactNode; dir?: string; @@ -180,7 +171,7 @@ export default function AnticipatedEAOSchedule() { showReportDateBanner={showReportDateBanner} /> - {Object.keys(reports).length > 0 && ( + {reports && reports.length > 0 && ( <> Select Type to Hide @@ -211,9 +202,15 @@ export default function AnticipatedEAOSchedule() { )} {resultStatus === RESULT_STATUS.LOADED && - Object.keys(reports) - .filter((key) => !selectedTypes.includes(key)) - .map((key) => { + reports && + reports + .filter((report) => { + const groupName = report.group; + return !selectedTypes.includes(groupName); + }) + .map((group, _) => { + const groupName = group.group; + const items = group.items; return ( <> }> - {key} + {groupName} - {((reports as any)[key] as []).map((item, itemIndex) => { + {items.map((item, itemIndex) => { console.log(item); return (