diff --git a/LichessWebView/app.py b/LichessWebView/app.py index 9919d8c..23f6ab6 100644 --- a/LichessWebView/app.py +++ b/LichessWebView/app.py @@ -117,11 +117,12 @@ def get_users(): tu.first_name, tu.last_name, tu.created_at, + tu.bot_language, COUNT(ug.id) as gamer_count, SUM(CASE WHEN ug.period_minutes > 0 THEN 1 ELSE 0 END) as monitored_gamers FROM telegram_users tu LEFT JOIN user_gamers ug ON tu.user_id = ug.user_id - GROUP BY tu.user_id, tu.username, tu.first_name, tu.last_name, tu.created_at + GROUP BY tu.user_id, tu.username, tu.first_name, tu.last_name, tu.created_at, tu.bot_language ORDER BY tu.created_at DESC ''') @@ -135,8 +136,9 @@ def get_users(): 'first_name': row[2] or '-', 'last_name': row[3], 'created_at': row[4], - 'gamer_count': row[5], - 'monitored_gamers': row[6] + 'bot_language': row[5] or 'en', # Default to 'en' if not set + 'gamer_count': row[6], + 'monitored_gamers': row[7] }) # Получаем общее количество игроков (уникальных) @@ -160,9 +162,18 @@ def get_users(): """) users_without_gamers = cursor.fetchone()[0] - # Calculate percentage + # Count users with Russian language + cursor.execute(""" + SELECT COUNT(DISTINCT tu.user_id) + FROM telegram_users tu + WHERE tu.bot_language = 'ru' + """) + users_with_ru_language = cursor.fetchone()[0] + + # Calculate percentages total_users = len(users) users_without_gamers_percent = round((users_without_gamers / total_users * 100)) if total_users > 0 else 0 + users_ru_language_percent = round((users_with_ru_language / total_users * 100)) if total_users > 0 else 0 # Count new gamers today (from user_gamers table) cursor.execute(""" @@ -192,6 +203,8 @@ def get_users(): 'users_today': users_today, 'users_without_gamers': users_without_gamers, 'users_without_gamers_percent': users_without_gamers_percent, + 'users_with_ru_language': users_with_ru_language, + 'users_ru_language_percent': users_ru_language_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 827d457..2121284 100644 --- a/LichessWebView/templates/index.html +++ b/LichessWebView/templates/index.html @@ -287,6 +287,7 @@