ru en in web interface
This commit is contained in:
parent
0c9a66a73c
commit
711adb4126
2 changed files with 27 additions and 6 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue