From 26b6ab8a3a48a5b1d6683c63e4f1dbdb7a996c92 Mon Sep 17 00:00:00 2001 From: Cameron Date: Wed, 29 Nov 2023 12:02:55 -0500 Subject: [PATCH] web/satellite: only fill charts with zero if day is complete Before this change we would fill all days on the chart with zero if no data existed. This led to concerns when users saw their stored data value drop to zero. Instead, we will leave incomplete days blank if there is no usage data. This includes today and future days. issue: https://github.com/storj/customer-issues/issues/1157 Change-Id: I4b9def392b89684fe63f1503274e868a240eb353 --- web/satellite/src/utils/chart.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/web/satellite/src/utils/chart.ts b/web/satellite/src/utils/chart.ts index 371a54182..7cf2b3cb6 100644 --- a/web/satellite/src/utils/chart.ts +++ b/web/satellite/src/utils/chart.ts @@ -26,6 +26,9 @@ export class ChartUtils { // Create new array of objects with date and corresponding data value with length of date range difference. const chartData: DataStamp[] = new Array(datesArr.length); + const today = new Date(); + today.setHours(0, 0, 0, 0); + // Fill new array. for (let i = 0; i < datesArr.length; i++) { // Find in fetched data a day-data value that corresponds to current iterable date. @@ -36,8 +39,10 @@ export class ChartUtils { continue; } - // If not found then fill new array with day and zero data value. - chartData[i] = DataStamp.emptyWithDate(datesArr[i]); + // If not found and day has passed then fill new array with day and zero data value. + if (datesArr[i].getTime() < today.getTime()) { + chartData[i] = DataStamp.emptyWithDate(datesArr[i]); + } } return chartData;