minor fixes

This commit is contained in:
Vladless
2025-11-17 00:47:06 +03:00
parent f44bd9e4b6
commit 679e65ec44
3 changed files with 50 additions and 7 deletions
+4 -2
View File
@@ -82,7 +82,8 @@ async def check_user_exists(session: AsyncSession, tg_id: int) -> bool:
async def get_balance(session: AsyncSession, tg_id: int) -> float:
result = await session.execute(select(func.coalesce(User.balance, 0.0)).where(User.tg_id == tg_id))
return round(float(result.scalar_one()), 1)
balance = result.scalar_one_or_none()
return round(float(balance or 0.0), 1)
async def set_user_balance(session: AsyncSession, tg_id: int, balance: float) -> None:
@@ -106,7 +107,8 @@ async def update_trial(session: AsyncSession, tg_id: int, status: int):
async def get_trial(session: AsyncSession, tg_id: int) -> int:
result = await session.execute(select(func.coalesce(User.trial, 0)).where(User.tg_id == tg_id))
return int(result.scalar_one())
trial = result.scalar_one_or_none()
return int(trial or 0)
async def upsert_user(