From 508b74c46ce1b233f4558b915f97be756e86749f Mon Sep 17 00:00:00 2001 From: Kabirdas Henry Date: Wed, 30 Dec 2020 21:56:52 -0800 Subject: [PATCH 1/2] prevent cumulative cases and deaths from being reset to 0 --- utils/formatGraph.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/utils/formatGraph.ts b/utils/formatGraph.ts index b313b8a2..1c256fc6 100644 --- a/utils/formatGraph.ts +++ b/utils/formatGraph.ts @@ -21,12 +21,14 @@ export default (data: DataType[]) => { let previousDayCases = 0 let deathSubTotal = 0 let deathPreviousDayCases = 0 + let cases = 0 + let deaths = 0 data .filter(d => new Date(d.date) > lastMonth) .forEach((d, idx, array) => { const date = new Date(d.date) - const cases = d.cases - const deaths = d.deaths + cases = d.cases || cases + deaths = d.deaths || deaths if (!isNaN(cases)) { if (cases === 0) { return From 4041a7b2309aa69df508fd5ce32c36179403fe9e Mon Sep 17 00:00:00 2001 From: Kabirdas Henry Date: Wed, 30 Dec 2020 21:58:35 -0800 Subject: [PATCH 2/2] set graph data start date to 1-23-20 --- utils/formatGraph.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/utils/formatGraph.ts b/utils/formatGraph.ts index 1c256fc6..92748791 100644 --- a/utils/formatGraph.ts +++ b/utils/formatGraph.ts @@ -14,9 +14,7 @@ type GraphDataType = { export default (data: DataType[]) => { const graphData: GraphDataType[] = [] - const today = new Date() - const lastMonth = new Date() - lastMonth.setMonth(today.getMonth() - 3) + const lastMonth = new Date('2020-01-23') let subTotal = 0 let previousDayCases = 0 let deathSubTotal = 0