From 17a26155cdf0150ea9d8cf915311f16fafa6354a Mon Sep 17 00:00:00 2001 From: Ildar Kamalov Date: Tue, 3 Sep 2019 11:03:47 +0300 Subject: [PATCH] - client: convert average processing time to milliseconds --- client/src/actions/stats.js | 3 ++- client/src/components/Dashboard/Counters.js | 2 +- client/src/helpers/helpers.js | 8 ++++++++ 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/client/src/actions/stats.js b/client/src/actions/stats.js index 65902e15..a24b3ec7 100644 --- a/client/src/actions/stats.js +++ b/client/src/actions/stats.js @@ -2,7 +2,7 @@ import { createAction } from 'redux-actions'; import Api from '../api/Api'; import { addErrorToast, addSuccessToast } from './index'; -import { normalizeTopStats } from '../helpers/helpers'; +import { normalizeTopStats, secondsToMilliseconds } from '../helpers/helpers'; const apiClient = new Api(); @@ -51,6 +51,7 @@ export const getStats = () => async (dispatch) => { top_blocked_domains: normalizeTopStats(stats.top_blocked_domains), top_clients: normalizeTopStats(stats.top_clients), top_queried_domains: normalizeTopStats(stats.top_queried_domains), + avg_processing_time: secondsToMilliseconds(stats.avg_processing_time), }; dispatch(getStatsSuccess(normalizedStats)); diff --git a/client/src/components/Dashboard/Counters.js b/client/src/components/Dashboard/Counters.js index 36ab78c6..95687d64 100644 --- a/client/src/components/Dashboard/Counters.js +++ b/client/src/components/Dashboard/Counters.js @@ -102,7 +102,7 @@ const Counters = (props) => { - {avgProcessingTime ? `${round(avgProcessingTime, 2)} ms` : 0} + {avgProcessingTime ? `${round(avgProcessingTime)} ms` : 0} diff --git a/client/src/helpers/helpers.js b/client/src/helpers/helpers.js index e84d2b27..ad0e94dd 100644 --- a/client/src/helpers/helpers.js +++ b/client/src/helpers/helpers.js @@ -233,3 +233,11 @@ export const sortClients = (clients) => { export const toggleAllServices = (services, change, isSelected) => { services.forEach(service => change(`blocked_services.${service.id}`, isSelected)); }; + +export const secondsToMilliseconds = (seconds) => { + if (seconds) { + return seconds * 1000; + } + + return seconds; +};