fix IFV graphs to use utc dates consistently to prevent never ending … (#7578)

* 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 <aryx.github@gmx-topmail.de>
This commit is contained in:
Joel Maher 2022-11-23 09:12:18 -08:00 коммит произвёл GitHub
Родитель 4c78f7d83c
Коммит 112fddcac7
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
1 изменённых файлов: 8 добавлений и 8 удалений

Просмотреть файл

@ -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;