add statistics

This commit is contained in:
vrubelroman 2025-11-13 13:32:46 +03:00
parent 23de80f94d
commit ceb62b408a
6 changed files with 318 additions and 3 deletions

View file

@ -250,6 +250,20 @@
Кол-во игроков: <strong id="total-gamers">0</strong>
</div>
<div class="stats" style="margin-top: 15px; padding: 15px; background: #f5f5f5; border-radius: 8px;">
<h3 style="margin-top: 0; margin-bottom: 10px; font-size: 16px;">📨 Счетчики сообщений</h3>
<div style="margin-bottom: 8px;">
Всего отправлено: <strong id="total-messages-all">0</strong>
</div>
<div style="margin-bottom: 8px;">
Сегодня отправлено: <strong id="total-messages-today">0</strong>
</div>
<div id="message-stats-by-command" style="margin-top: 10px; font-size: 12px; color: #666;">
<div style="margin-bottom: 5px;"><strong>По командам:</strong></div>
<div id="command-stats-list"></div>
</div>
</div>
<div class="search-box">
<input type="text" id="search-input" placeholder="Поиск по имени или никнейму...">
</div>
@ -292,6 +306,45 @@
users = data.users;
document.getElementById('total-users').textContent = data.total_users;
document.getElementById('total-gamers').textContent = data.total_gamers;
// Update message counters
if (data.message_stats) {
document.getElementById('total-messages-all').textContent = data.message_stats.total_all_time || 0;
document.getElementById('total-messages-today').textContent = data.message_stats.total_today || 0;
// Render command stats
const commandStatsList = document.getElementById('command-stats-list');
if (data.message_stats.by_command && Object.keys(data.message_stats.by_command).length > 0) {
const commandNames = {
'addgamer': 'Add Gamer',
'addtoken': 'Add Token',
'getgamers': 'Get Gamers',
'delgamer': 'Del Gamer',
'today': 'Today',
'yesterday': 'Yesterday',
'week': 'Week',
'setperiod': 'Set Period',
'periodic_notification': 'Periodic Notifications'
};
// Filter out excluded commands
const excludedCommands = ['start', 'lang', 'resetlang'];
const filteredCommands = Object.entries(data.message_stats.by_command)
.filter(([cmd]) => !excludedCommands.includes(cmd));
commandStatsList.innerHTML = filteredCommands
.sort((a, b) => b[1].total - a[1].total)
.map(([cmd, stats]) => {
const cmdName = commandNames[cmd] || cmd;
return `<div style="margin-bottom: 3px;">
${cmdName}: <strong>${stats.total}</strong> (сегодня: <strong>${stats.today}</strong>)
</div>`;
}).join('');
} else {
commandStatsList.innerHTML = '<div style="color: #999;">Нет данных</div>';
}
}
filteredUsers = users;
renderUsers();