From 1ea444791b9982e376acb4011514a42a3395e01e Mon Sep 17 00:00:00 2001 From: dv Date: Wed, 15 Apr 2026 10:24:10 +0300 Subject: [PATCH] =?UTF-8?q?=D1=84=D0=B8=D0=BA=D1=81=20=D1=81=D1=82=D0=B0?= =?UTF-8?q?=D1=82=D0=B8=D1=81=D1=82=D0=B8=D0=BA=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .claude/settings.local.json | 3 ++- public/js/statistics.js | 28 +++++++++++++++++----------- 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/.claude/settings.local.json b/.claude/settings.local.json index de745e1..e940a3b 100644 --- a/.claude/settings.local.json +++ b/.claude/settings.local.json @@ -1,7 +1,8 @@ { "permissions": { "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)" ] } } diff --git a/public/js/statistics.js b/public/js/statistics.js index 7b74137..3abdca3 100644 --- a/public/js/statistics.js +++ b/public/js/statistics.js @@ -839,18 +839,24 @@ function renderClientUsersCard() { const wrap = document.getElementById('stats-client-users-wrap'); if (!wrap) return; - // Собираем: клиент → { total, users: { username → count } } + // _clientname — организация (из справочника по clientid) + // clientname — сырое поле API: имя контакта/заявителя когда _clientname задан, + // либо имя организации если clientid не задан + // Собираем: организация → { total, users: { contactName → count } } const cMap = {}; - // Сначала добавляем всех клиентов, которые есть в allData, с нулями - allData.forEach(({task: t}) => { - const name = t._clientname || t.clientname || 'Неизвестно'; - if (!cMap[name]) cMap[name] = { total: 0, users: {} }; - }); - allData.forEach(({task: t}) => { - const name = t._clientname || t.clientname || 'Неизвестно'; - cMap[name].total++; - const user = t.username || '—'; - cMap[name].users[user] = (cMap[name].users[user] || 0) + 1; + allData.forEach((item) => { + const t = item.task; + const org = t._clientname || t.clientname || 'Неизвестно'; + // Контакт: clientname когда есть отдельное _clientname (org), иначе lastComment автор + let contact; + if (t._clientname && t.clientname && t._clientname !== t.clientname) { + contact = t.clientname; + } else { + contact = item.lastComment?.username || t.updatedby || '—'; + } + 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);