diff --git a/client/src/api/Api.js b/client/src/api/Api.js index 4f7923ec..1ba54271 100644 --- a/client/src/api/Api.js +++ b/client/src/api/Api.js @@ -1,6 +1,5 @@ import axios from 'axios'; -import startOfToday from 'date-fns/start_of_today'; -import endOfToday from 'date-fns/end_of_today'; +import subHours from 'date-fns/sub_hours'; import dateFormat from 'date-fns/format'; export default class Api { @@ -51,13 +50,12 @@ export default class Api { getGlobalStatsHistory() { const { path, method } = this.GLOBAL_STATS_HISTORY; const format = 'YYYY-MM-DDTHH:mm:ssZ'; - const todayStart = dateFormat(startOfToday(), format); - const todayEnd = dateFormat(endOfToday(), format); + const dateNow = Date.now(); const config = { params: { - start_time: todayStart, - end_time: todayEnd, + start_time: dateFormat(subHours(dateNow, 24), format), + end_time: dateFormat(dateNow, format), time_unit: 'hours', }, }; diff --git a/client/src/components/Dashboard/Statistics.js b/client/src/components/Dashboard/Statistics.js index fa556079..de98e19c 100644 --- a/client/src/components/Dashboard/Statistics.js +++ b/client/src/components/Dashboard/Statistics.js @@ -5,7 +5,7 @@ import PropTypes from 'prop-types'; import Card from '../ui/Card'; const Statistics = props => ( - + {props.history ? ( tickSize: 5, tickPadding: 5, tickRotation: -45, - legend: 'time', legendOffset: 50, legendPosition: 'center', }} @@ -32,7 +31,6 @@ const Statistics = props => ( tickSize: 5, tickPadding: 5, tickRotation: 0, - legend: 'count', legendOffset: -40, legendPosition: 'center', }} diff --git a/client/src/helpers/helpers.js b/client/src/helpers/helpers.js index e186047c..d6269d8a 100644 --- a/client/src/helpers/helpers.js +++ b/client/src/helpers/helpers.js @@ -1,6 +1,6 @@ import dateParse from 'date-fns/parse'; import dateFormat from 'date-fns/format'; -import startOfToday from 'date-fns/start_of_today'; +import subHours from 'date-fns/sub_hours'; import addHours from 'date-fns/add_hours'; import round from 'lodash/round'; @@ -37,10 +37,10 @@ export const normalizeLogs = logs => logs.map((log) => { export const normalizeHistory = history => Object.keys(history).map((key) => { const id = key.replace(/_/g, ' ').replace(/^\w/, c => c.toUpperCase()); - const today = startOfToday(); + const dayAgo = subHours(Date.now(), 24); const data = history[key].map((item, index) => { - const formatHour = dateFormat(addHours(today, index), 'HH:mm'); + const formatHour = dateFormat(addHours(dayAgo, index), 'ddd HH:00'); const roundValue = round(item, 2); return {