diff --git a/LichessClientTG_bot/admin_bot.py b/LichessClientTG_bot/admin_bot.py index 7836c1a..66e9931 100644 --- a/LichessClientTG_bot/admin_bot.py +++ b/LichessClientTG_bot/admin_bot.py @@ -167,6 +167,18 @@ class AdminBot: 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 + users_without_gamers_percent = round((users_without_gamers / users_count * 100)) if users_count > 0 else 0 + # Count unique gamers cursor.execute("SELECT COUNT(DISTINCT username) FROM gamers") gamers_count = cursor.fetchone()[0] @@ -201,6 +213,7 @@ class AdminBot: message = ( f"📊 Статистика базы данных\n\n" f"👥 Пользователей Telegram: {users_count} (сегодня: {users_today})\n" + f"👤 Пользователей без игроков: {users_without_gamers} ({users_without_gamers_percent}%)\n" f"🎮 Отслеживаемых игроков: {gamers_count} (сегодня: {gamers_today})\n\n" f"📨 Счетчики сообщений\n\n" f"Всего отправлено: {stats['total_all_time']}\n" diff --git a/LichessWebView/app.py b/LichessWebView/app.py index 5046122..9919d8c 100644 --- a/LichessWebView/app.py +++ b/LichessWebView/app.py @@ -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 diff --git a/LichessWebView/templates/index.html b/LichessWebView/templates/index.html index de0d378..827d457 100644 --- a/LichessWebView/templates/index.html +++ b/LichessWebView/templates/index.html @@ -286,6 +286,7 @@