new users and gamers today

This commit is contained in:
vrubelroman 2025-11-18 14:30:55 +03:00
parent 141022727d
commit 8a813be5cc

View file

@ -113,6 +113,7 @@ class AdminBot:
"""Status command - show statistics""" """Status command - show statistics"""
try: try:
import sqlite3 import sqlite3
from datetime import date
conn = sqlite3.connect(self.db.db_path) conn = sqlite3.connect(self.db.db_path)
cursor = conn.cursor() cursor = conn.cursor()
@ -120,10 +121,24 @@ class AdminBot:
cursor.execute("SELECT COUNT(*) FROM telegram_users") cursor.execute("SELECT COUNT(*) FROM telegram_users")
users_count = cursor.fetchone()[0] users_count = cursor.fetchone()[0]
# Count new users today
today = date.today().isoformat()
cursor.execute("SELECT COUNT(*) FROM telegram_users WHERE DATE(created_at) = ?", (today,))
users_today = cursor.fetchone()[0]
# Count unique gamers # Count unique gamers
cursor.execute("SELECT COUNT(DISTINCT username) FROM gamers") cursor.execute("SELECT COUNT(DISTINCT username) FROM gamers")
gamers_count = cursor.fetchone()[0] gamers_count = cursor.fetchone()[0]
# Count new gamers today (from user_gamers table)
cursor.execute("""
SELECT COUNT(DISTINCT g.id)
FROM user_gamers ug
JOIN gamers g ON ug.gamer_id = g.id
WHERE DATE(ug.created_at) = ?
""", (today,))
gamers_today = cursor.fetchone()[0]
conn.close() conn.close()
# Get message counters statistics # Get message counters statistics
@ -144,8 +159,8 @@ class AdminBot:
message = ( message = (
f"📊 <b>Статистика базы данных</b>\n\n" f"📊 <b>Статистика базы данных</b>\n\n"
f"👥 Пользователей Telegram: {users_count}\n" f"👥 Пользователей Telegram: {users_count} (сегодня: {users_today})\n"
f"🎮 Отслеживаемых игроков: {gamers_count}\n\n" f"🎮 Отслеживаемых игроков: {gamers_count} (сегодня: {gamers_today})\n\n"
f"📨 <b>Счетчики сообщений</b>\n\n" f"📨 <b>Счетчики сообщений</b>\n\n"
f"Всего отправлено: <b>{stats['total_all_time']}</b>\n" f"Всего отправлено: <b>{stats['total_all_time']}</b>\n"
f"Сегодня отправлено: <b>{stats['total_today']}</b>\n\n" f"Сегодня отправлено: <b>{stats['total_today']}</b>\n\n"