DispelEvilBot/bot/services/stats.py

14 lines
380 B
Python

"""Сервис статистики."""
from __future__ import annotations
from common.models import TopEntry
from common.repositories import stats_repo
async def top_users() -> list[TopEntry]:
rows = await stats_repo.get_top_list()
return [
TopEntry(username=row.get("username"), nick=row.get("nick"), count=int(row.get("count") or 0)) for row in rows
]