From 112fddcac7017c45387e990abfe0a7caa2a493da Mon Sep 17 00:00:00 2001 From: Joel Maher Date: Wed, 23 Nov 2022 09:12:18 -0800 Subject: [PATCH] =?UTF-8?q?fix=20IFV=20graphs=20to=20use=20utc=20dates=20c?= =?UTF-8?q?onsistently=20to=20prevent=20never=20ending=20=E2=80=A6=20(#757?= =?UTF-8?q?8)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix IFV graphs to use utc dates consistently to prevent never ending spinner * IFV: only use UTC when looping over days * also switch this to moment.utc * fix graph x axis display date, increment day via moment, and use moment date as index for counter Co-authored-by: Sebastian Hengst --- ui/intermittent-failures/View.jsx | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/ui/intermittent-failures/View.jsx b/ui/intermittent-failures/View.jsx index 07da08662..e9071fd88 100644 --- a/ui/intermittent-failures/View.jsx +++ b/ui/intermittent-failures/View.jsx @@ -12,7 +12,7 @@ import { } from '../helpers/url'; import { getData } from '../helpers/http'; -import { validateQueryParams, mergeData, formatBugs, ISODate } from './helpers'; +import { validateQueryParams, mergeData, formatBugs } from './helpers'; const withView = (defaultState) => (WrappedComponent) => { class View extends React.Component { @@ -130,21 +130,21 @@ const withView = (defaultState) => (WrappedComponent) => { uniqueFrequency[hash] = [ { data: [], color: 'red', dates: {}, datemap: {}, count: 0 }, ]; - let start = ISODate(moment(startday).utc()); - const end = ISODate(moment(endday).utc()); + let start = moment.utc(startday); + const end = moment.utc(endday); // create entry for each date in range so graph looks nice. while (start <= end) { - const sdate = moment(start).format('MMM DD'); + const sdate = start.format('MMM DD'); uniqueFrequency[hash][0].dates[sdate] = 0; - uniqueFrequency[hash][0].datemap[sdate] = start; - start = ISODate(moment(start).utc().add(1, 'days')); + uniqueFrequency[hash][0].datemap[sdate] = start.format('ddd DD'); + start = start.add(1, 'days'); } } // store frequency data by date to use in graphs, etc. const date = result[2].split(' ')[0]; - const sdate = moment(date).format('MMM DD'); - if (!(date in uniqueFrequency[hash][0].dates)) { + const sdate = moment.utc(date).format('MMM DD'); + if (!(sdate in uniqueFrequency[hash][0].dates)) { uniqueFrequency[hash][0].dates[sdate] = 0; } uniqueFrequency[hash][0].dates[sdate] += 1;