count users without gamers
This commit is contained in:
parent
ef9aa3d3df
commit
faf6ec0c35
3 changed files with 32 additions and 1 deletions
|
|
@ -151,6 +151,19 @@ def get_users():
|
|||
cursor.execute("SELECT COUNT(*) FROM telegram_users WHERE DATE(created_at) = ?", (today,))
|
||||
users_today = cursor.fetchone()[0]
|
||||
|
||||
# Count users without gamers
|
||||
cursor.execute("""
|
||||
SELECT COUNT(DISTINCT tu.user_id)
|
||||
FROM telegram_users tu
|
||||
LEFT JOIN user_gamers ug ON tu.user_id = ug.user_id
|
||||
WHERE ug.id IS NULL
|
||||
""")
|
||||
users_without_gamers = cursor.fetchone()[0]
|
||||
|
||||
# Calculate percentage
|
||||
total_users = len(users)
|
||||
users_without_gamers_percent = round((users_without_gamers / total_users * 100)) if total_users > 0 else 0
|
||||
|
||||
# Count new gamers today (from user_gamers table)
|
||||
cursor.execute("""
|
||||
SELECT COUNT(DISTINCT g.id)
|
||||
|
|
@ -175,8 +188,10 @@ def get_users():
|
|||
return jsonify({
|
||||
'success': True,
|
||||
'users': users,
|
||||
'total_users': len(users),
|
||||
'total_users': total_users,
|
||||
'users_today': users_today,
|
||||
'users_without_gamers': users_without_gamers,
|
||||
'users_without_gamers_percent': users_without_gamers_percent,
|
||||
'total_gamers': total_gamers,
|
||||
'gamers_today': gamers_today,
|
||||
'message_stats': message_stats
|
||||
|
|
|
|||
|
|
@ -286,6 +286,7 @@
|
|||
|
||||
<div class="stats">
|
||||
Всего пользователей: <strong id="total-users">0</strong> (сегодня: <strong id="users-today">0</strong>)<br>
|
||||
👤 Пользователей без игроков: <strong id="users-without-gamers">0</strong> (<strong id="users-without-gamers-percent">0</strong>%)<br>
|
||||
Кол-во игроков: <strong id="total-gamers">0</strong> (сегодня: <strong id="gamers-today">0</strong>)
|
||||
</div>
|
||||
|
||||
|
|
@ -353,6 +354,8 @@
|
|||
users = data.users;
|
||||
document.getElementById('total-users').textContent = data.total_users;
|
||||
document.getElementById('users-today').textContent = data.users_today || 0;
|
||||
document.getElementById('users-without-gamers').textContent = data.users_without_gamers || 0;
|
||||
document.getElementById('users-without-gamers-percent').textContent = data.users_without_gamers_percent || 0;
|
||||
document.getElementById('total-gamers').textContent = data.total_gamers;
|
||||
document.getElementById('gamers-today').textContent = data.gamers_today || 0;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue