Skip to content

Commit

Permalink
Added exclusion filter for work phases (#2247)
Browse files Browse the repository at this point in the history
* Added filtering by work phase exclusion

* Added filtering by work phase exclusion

* filter values fixed

* Fixed review comments
  • Loading branch information
saravanpa-aot authored May 23, 2024
1 parent 1f775b3 commit 89601f3
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
6 changes: 5 additions & 1 deletion epictrack-api/src/api/reports/anticipated_schedule_report.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,9 @@ def _fetch_data(self, report_date):
next_pecp_query = self._get_next_pcp_query(start_date)
referral_event_query = self._get_referral_event_query(start_date)
latest_status_updates = self._get_latest_status_update_query()

exclude_phase_names = []
if self.filters and "exclude" in self.filters:
exclude_phase_names = self.filters["exclude"]
results_qry = (
db.session.query(Work)
.join(Event, Event.work_id == Work.id)
Expand Down Expand Up @@ -132,6 +134,8 @@ def _fetch_data(self, report_date):
Work.work_state.in_(
[WorkStateEnum.IN_PROGRESS.value, WorkStateEnum.SUSPENDED.value]
),
# Filter out specific WorkPhase names
~WorkPhase.name.in_(exclude_phase_names)
)
.add_columns(
PhaseCode.name.label("phase_name"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,16 @@ export default function AnticipatedEAOSchedule() {
const downloadPDFReport = React.useCallback(async () => {
try {
fetchReportData();
let filtersToSend = {};

if (selectedTypes.length > 0) {
filtersToSend = { exclude: selectedTypes };
}
const binaryReponse = await ReportService.downloadPDF(
REPORT_TYPE.EA_REFERRAL,
{
report_date: reportDate,
filters: filtersToSend,
}
);
const url = window.URL.createObjectURL(
Expand All @@ -107,7 +113,7 @@ export default function AnticipatedEAOSchedule() {
} catch (error) {
setResultStatus(RESULT_STATUS.ERROR);
}
}, [reportDate, fetchReportData]);
}, [reportDate, fetchReportData, selectedTypes]);

const handleTabChange = (event: React.SyntheticEvent, newValue: number) => {
setSelectedTab(newValue);
Expand Down Expand Up @@ -194,7 +200,9 @@ export default function AnticipatedEAOSchedule() {
autoFocus
multiple
value={selectedTypes}
onChange={(e, value) => setSelectedTypes(value)}
onChange={(e, value) => {
setSelectedTypes(value);
}}
options={typeFilter}
renderInput={(params) => (
<TextField {...params} variant="standard" />
Expand Down

0 comments on commit 89601f3

Please sign in to comment.