stats: show linked email + tg_id counts

This commit is contained in:
Vladless
2026-05-07 15:15:27 +00:00
parent bf09fbac26
commit 6ebaff08e8
2 changed files with 18 additions and 1 deletions
+9 -1
View File
@@ -4,13 +4,21 @@ from sqlalchemy import and_, exists, func, not_, select
from sqlalchemy.ext.asyncio import AsyncSession
from core.constants import PAYMENT_SYSTEMS_EXCLUDED
from database.models import Key, Payment, Referral, Tariff, User
from database.models import Identity, Key, Payment, Referral, Tariff, User
async def count_total_users(session: AsyncSession) -> int:
return await session.scalar(select(func.count()).select_from(User))
async def count_users_with_tg_id(session: AsyncSession) -> int:
return await session.scalar(select(func.count()).select_from(User).where(User.tg_id.isnot(None)))
async def count_identities_with_email(session: AsyncSession) -> int:
return await session.scalar(select(func.count()).select_from(Identity).where(Identity.email.isnot(None)))
async def count_users_updated_today(session: AsyncSession, today: date) -> int:
return await session.scalar(select(func.count()).select_from(User).where(User.updated_at >= today))