Merge - client: fix logic of top clients normalization
Close #1294 * commit '392535ce3aad89fad52074399ec7b6986de8c4e9': - client: change code style of top clients normalization helper - client: fix logic of top clients normalization
This commit is contained in:
@@ -261,12 +261,27 @@ export const redirectToCurrentProtocol = (values, httpPort = 80) => {
|
||||
|
||||
export const normalizeTextarea = text => text && text.replace(/[;, ]/g, '\n').split('\n').filter(n => n);
|
||||
|
||||
export const normalizeTopClients = clients => clients.reduce((accumulator, clientObj) => {
|
||||
const { name, count } = clientObj;
|
||||
/**
|
||||
* Normalizes the topClients array
|
||||
*
|
||||
* @param {Object[]} topClients
|
||||
* @param {string} topClients.name
|
||||
* @param {number} topClients.count
|
||||
* @param {Object} topClients.info
|
||||
* @param {string} topClients.info.name
|
||||
* @returns {Object} normalizedTopClients
|
||||
* @returns {Object.<string, number>} normalizedTopClients.auto - auto clients
|
||||
* @returns {Object.<string, number>} normalizedTopClients.configured - configured clients
|
||||
*/
|
||||
|
||||
export const normalizeTopClients = topClients => topClients.reduce((nameToCountMap, clientObj) => {
|
||||
const { name, count, info: { name: infoName } } = clientObj;
|
||||
// eslint-disable-next-line no-param-reassign
|
||||
accumulator[name] = count;
|
||||
return accumulator;
|
||||
}, {});
|
||||
nameToCountMap.auto[name] = count;
|
||||
// eslint-disable-next-line no-param-reassign
|
||||
nameToCountMap.configured[infoName] = count;
|
||||
return nameToCountMap;
|
||||
}, { auto: {}, configured: {} });
|
||||
|
||||
export const getClientInfo = (clients, ip) => {
|
||||
const client = clients
|
||||
|
||||
Reference in New Issue
Block a user