Добавлен счётчик уникальных пользователей за сегодня в /stat
All checks were successful
CI/CD Pipeline / build-and-deploy (push) Successful in 7s
All checks were successful
CI/CD Pipeline / build-and-deploy (push) Successful in 7s
This commit is contained in:
parent
6259dcb3e5
commit
c7c0067881
2 changed files with 6 additions and 1 deletions
|
|
@ -36,7 +36,8 @@ async def stat(update: Update, context: ContextTypes.DEFAULT_TYPE):
|
|||
'*📊 Статистика chessCalc*\n\n'
|
||||
f'👤 Уникальных пользователей: *{stats["unique_users"]}*\n'
|
||||
f'🔢 Всего запросов: *{stats["total_requests"]}*\n'
|
||||
f'📅 За сегодня: *{stats["today_requests"]}*'
|
||||
f'📅 За сегодня запросов: *{stats["today_requests"]}*\n'
|
||||
f'👥 Из них уникальных: *{stats["today_unique_users"]}*'
|
||||
)
|
||||
await update.message.reply_text(text, parse_mode=ParseMode.MARKDOWN_V2)
|
||||
|
||||
|
|
|
|||
|
|
@ -87,9 +87,13 @@ def get_stats() -> dict:
|
|||
today_requests = conn.execute(
|
||||
"SELECT COUNT(*) FROM requests WHERE date(timestamp) = ?",
|
||||
(today,)).fetchone()[0]
|
||||
today_unique_users = conn.execute(
|
||||
"SELECT COUNT(DISTINCT user_id) FROM requests WHERE date(timestamp) = ?",
|
||||
(today,)).fetchone()[0]
|
||||
conn.close()
|
||||
return {
|
||||
'unique_users': unique_users,
|
||||
'total_requests': total_requests,
|
||||
'today_requests': today_requests,
|
||||
'today_unique_users': today_unique_users,
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue