From d4e5092a58b1d7391110cae1eac990c6805e25ed Mon Sep 17 00:00:00 2001 From: Chukwudumebi Onwuli <37223065+deeonwuli@users.noreply.github.com> Date: Wed, 11 Dec 2024 15:19:14 +0100 Subject: [PATCH 1/3] fix: show only items with "ALL" incident status --- src/data/repositories/PerformanceOverviewD2Repository.ts | 4 ++-- .../disease-outbreak-event/PerformanceOverviewMetrics.ts | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/data/repositories/PerformanceOverviewD2Repository.ts b/src/data/repositories/PerformanceOverviewD2Repository.ts index c0dc874b..a002f144 100644 --- a/src/data/repositories/PerformanceOverviewD2Repository.ts +++ b/src/data/repositories/PerformanceOverviewD2Repository.ts @@ -109,7 +109,7 @@ export class PerformanceOverviewD2Repository implements PerformanceOverviewRepos existingEntry.total += totalCardCount.total; acc[totalCardCount.name] = existingEntry; } else { - acc[totalCardCount.name] = totalCardCount; + acc[totalCardCount.name] = { ...totalCardCount }; } return acc; }, {} as Record); @@ -190,7 +190,7 @@ export class PerformanceOverviewD2Repository implements PerformanceOverviewRepos if (filters && Object.entries(filters).length) { return Object.entries(filters).every(([key, value]) => { if (!value) { - return true; + return item.incidentStatus === "ALL"; } if (key === "incidentStatus") { return value === item.incidentStatus; diff --git a/src/domain/entities/disease-outbreak-event/PerformanceOverviewMetrics.ts b/src/domain/entities/disease-outbreak-event/PerformanceOverviewMetrics.ts index 9a1c3634..59596a6b 100644 --- a/src/domain/entities/disease-outbreak-event/PerformanceOverviewMetrics.ts +++ b/src/domain/entities/disease-outbreak-event/PerformanceOverviewMetrics.ts @@ -53,7 +53,7 @@ export type PerformanceOverviewMetrics = { nationalIncidentStatus: string; }; -export type IncidentStatus = "Watch" | "Alert" | "Respond" | "All"; +export type IncidentStatus = "Watch" | "Alert" | "Respond" | "ALL"; type BaseCounts = { name: DiseaseNames | HazardNames; From d0d765fbc2dceefed13f6e8215d256a4090fa23c Mon Sep 17 00:00:00 2001 From: Chukwudumebi Onwuli <37223065+deeonwuli@users.noreply.github.com> Date: Wed, 11 Dec 2024 21:35:48 +0100 Subject: [PATCH 2/3] fix: filter for total card counts correctly --- .../PerformanceOverviewD2Repository.ts | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/src/data/repositories/PerformanceOverviewD2Repository.ts b/src/data/repositories/PerformanceOverviewD2Repository.ts index a002f144..c93e41ae 100644 --- a/src/data/repositories/PerformanceOverviewD2Repository.ts +++ b/src/data/repositories/PerformanceOverviewD2Repository.ts @@ -188,16 +188,13 @@ export class PerformanceOverviewD2Repository implements PerformanceOverviewRepos const filteredCounts: TotalCardCounts[] = counts.filter(item => { if (filters && Object.entries(filters).length) { - return Object.entries(filters).every(([key, value]) => { - if (!value) { - return item.incidentStatus === "ALL"; - } - if (key === "incidentStatus") { - return value === item.incidentStatus; - } else if (key === "disease" || key === "hazard") { - return value === item.name; - } - }); + const matchesDisease = !filters.disease || item.name === filters.disease; + const matchesHazard = !filters.hazard || item.type === "hazard"; + const matchesIncidentStatus = !filters.incidentStatus + ? item.incidentStatus === "ALL" + : item.incidentStatus === filters.incidentStatus; + + return matchesDisease && matchesHazard && matchesIncidentStatus; } return true; }); From b75586a391ff8573ccaa3b4a2dbb82d424f75d60 Mon Sep 17 00:00:00 2001 From: Chukwudumebi Onwuli <37223065+deeonwuli@users.noreply.github.com> Date: Thu, 12 Dec 2024 13:15:29 +0100 Subject: [PATCH 3/3] fix: filter for hazard and disease type correctly --- src/data/repositories/PerformanceOverviewD2Repository.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/data/repositories/PerformanceOverviewD2Repository.ts b/src/data/repositories/PerformanceOverviewD2Repository.ts index c93e41ae..482640da 100644 --- a/src/data/repositories/PerformanceOverviewD2Repository.ts +++ b/src/data/repositories/PerformanceOverviewD2Repository.ts @@ -188,8 +188,10 @@ export class PerformanceOverviewD2Repository implements PerformanceOverviewRepos const filteredCounts: TotalCardCounts[] = counts.filter(item => { if (filters && Object.entries(filters).length) { - const matchesDisease = !filters.disease || item.name === filters.disease; - const matchesHazard = !filters.hazard || item.type === "hazard"; + const matchesDisease = + !filters.disease || (item.type === "disease" && item.name === filters.disease); + const matchesHazard = + !filters.hazard || (item.type === "hazard" && item.name === filters.hazard); const matchesIncidentStatus = !filters.incidentStatus ? item.incidentStatus === "ALL" : item.incidentStatus === filters.incidentStatus;