This commit is contained in:
parent
621c6407fe
commit
1ea444791b
2 changed files with 19 additions and 12 deletions
|
|
@ -1,7 +1,8 @@
|
||||||
{
|
{
|
||||||
"permissions": {
|
"permissions": {
|
||||||
"allow": [
|
"allow": [
|
||||||
"Bash(node -e ':*)"
|
"Bash(node -e ':*)",
|
||||||
|
"Bash(grep -n \"allData\\\\s*=\\\\|allData\\\\.push\\\\|task:.*lastComment\\\\|{task,\\\\|{ task,\" /c/Users/Professional/Documents/VSCode/intra_git/intradesk-monitor/public/js/ui.js)"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -839,18 +839,24 @@ function renderClientUsersCard() {
|
||||||
const wrap = document.getElementById('stats-client-users-wrap');
|
const wrap = document.getElementById('stats-client-users-wrap');
|
||||||
if (!wrap) return;
|
if (!wrap) return;
|
||||||
|
|
||||||
// Собираем: клиент → { total, users: { username → count } }
|
// _clientname — организация (из справочника по clientid)
|
||||||
|
// clientname — сырое поле API: имя контакта/заявителя когда _clientname задан,
|
||||||
|
// либо имя организации если clientid не задан
|
||||||
|
// Собираем: организация → { total, users: { contactName → count } }
|
||||||
const cMap = {};
|
const cMap = {};
|
||||||
// Сначала добавляем всех клиентов, которые есть в allData, с нулями
|
allData.forEach((item) => {
|
||||||
allData.forEach(({task: t}) => {
|
const t = item.task;
|
||||||
const name = t._clientname || t.clientname || 'Неизвестно';
|
const org = t._clientname || t.clientname || 'Неизвестно';
|
||||||
if (!cMap[name]) cMap[name] = { total: 0, users: {} };
|
// Контакт: clientname когда есть отдельное _clientname (org), иначе lastComment автор
|
||||||
});
|
let contact;
|
||||||
allData.forEach(({task: t}) => {
|
if (t._clientname && t.clientname && t._clientname !== t.clientname) {
|
||||||
const name = t._clientname || t.clientname || 'Неизвестно';
|
contact = t.clientname;
|
||||||
cMap[name].total++;
|
} else {
|
||||||
const user = t.username || '—';
|
contact = item.lastComment?.username || t.updatedby || '—';
|
||||||
cMap[name].users[user] = (cMap[name].users[user] || 0) + 1;
|
}
|
||||||
|
if (!cMap[org]) cMap[org] = { total: 0, users: {} };
|
||||||
|
cMap[org].total++;
|
||||||
|
cMap[org].users[contact] = (cMap[org].users[contact] || 0) + 1;
|
||||||
});
|
});
|
||||||
|
|
||||||
const entries = Object.entries(cMap).sort((a, b) => b[1].total - a[1].total);
|
const entries = Object.entries(cMap).sort((a, b) => b[1].total - a[1].total);
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue