Pull request: all: fix client id handling in querylog
Merge in DNS/adguard-home from 2607-querylog-client-id to master Closes #2607. Squashed commit of the following: commit 95367a82469af3b042489fb650b962b48cb73236 Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Thu Jan 28 19:02:02 2021 +0300 all: fix client, imp docs commit b652a7ef2373a75f7e897d29f5c9e36b0e076f8e Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Thu Jan 28 18:36:17 2021 +0300 all: fix client id handling in querylog
This commit is contained in:
@@ -12,7 +12,7 @@ const enrichWithClientInfo = async (logs) => {
|
||||
|
||||
if (Object.keys(clientsParams).length > 0) {
|
||||
const clients = await apiClient.findClients(clientsParams);
|
||||
return addClientInfo(logs, clients, 'client');
|
||||
return addClientInfo(logs, clients, 'client_id', 'client');
|
||||
}
|
||||
|
||||
return logs;
|
||||
|
||||
@@ -128,12 +128,21 @@ export const normalizeTopStats = (stats) => (
|
||||
}))
|
||||
);
|
||||
|
||||
export const addClientInfo = (data, clients, param) => data.map((row) => {
|
||||
const clientIp = row[param];
|
||||
const info = clients.find((item) => item[clientIp]) || '';
|
||||
export const addClientInfo = (data, clients, ...params) => data.map((row) => {
|
||||
let info = '';
|
||||
params.find((param) => {
|
||||
const id = row[param];
|
||||
if (id) {
|
||||
const client = clients.find((item) => item[id]) || '';
|
||||
info = client?.[id] ?? '';
|
||||
}
|
||||
|
||||
return info;
|
||||
});
|
||||
|
||||
return {
|
||||
...row,
|
||||
info: info?.[clientIp] ?? '',
|
||||
info,
|
||||
};
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user