Некоторые поправки что бы всё работало
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
from datetime import datetime
|
||||
import sys
|
||||
from fastapi import APIRouter, Depends, HTTPException
|
||||
from fastapi.exceptions import HTTPException
|
||||
@@ -108,7 +109,7 @@ async def last_transactions(
|
||||
"""
|
||||
logger.info(f"Получен запрос на транзакции для пользователя: {telegram_id}")
|
||||
try:
|
||||
logger.info(f"Вызов метода get_transaction с user_id={telegram_id}")
|
||||
logger.debug(f"Вызов метода get_transaction с user_id={telegram_id}")
|
||||
transactions = await db_manager.get_transaction(telegram_id)
|
||||
|
||||
if transactions == "ERROR":
|
||||
@@ -118,15 +119,30 @@ async def last_transactions(
|
||||
response = []
|
||||
logger.info(f"Формирование ответа для пользователя {telegram_id}: {response}")
|
||||
return response
|
||||
logger.info(f"Транзакции для {telegram_id}: {transactions}")
|
||||
response = [
|
||||
{
|
||||
|
||||
logger.debug(f"Транзакции для {telegram_id}: {transactions}")
|
||||
response = []
|
||||
for tx in transactions:
|
||||
# Проверяем, что транзакция существует и имеет created_at
|
||||
if tx is None:
|
||||
continue
|
||||
if tx.status.value == "pending":
|
||||
continue
|
||||
|
||||
# Обрабатываем created_at (может быть None)
|
||||
created_at_str = None
|
||||
if tx.created_at:
|
||||
created_at_str = tx.created_at.isoformat()
|
||||
else:
|
||||
created_at_str = datetime.utcnow().isoformat() # или любое значение по умолчанию
|
||||
|
||||
response.append({
|
||||
"id": tx.id,
|
||||
"amount": tx.amount,
|
||||
"created_at": tx.created_at.isoformat(),
|
||||
"type": tx.type,
|
||||
} for tx in transactions
|
||||
]
|
||||
"amount": float(tx.amount) if tx.amount else 0.0,
|
||||
"created_at": created_at_str,
|
||||
"type": tx.type.value if hasattr(tx.type, 'value') else str(tx.type),
|
||||
})
|
||||
|
||||
logger.info(f"Формирование ответа для пользователя {telegram_id}: {response}")
|
||||
return response
|
||||
|
||||
@@ -143,7 +159,6 @@ async def last_transactions(
|
||||
raise HTTPException(status_code=500, detail=str(e))
|
||||
|
||||
|
||||
|
||||
@router.post("/user/{referrer_id}/add_referral", summary="Обновить баланс")
|
||||
async def add_referal(
|
||||
referrer_id: int,
|
||||
|
||||
Reference in New Issue
Block a user