Сделал вроде меню как хотели
This commit is contained in:
@@ -81,7 +81,7 @@ class DatabaseManager:
|
||||
|
||||
async def last_subscription(self, user_id: int):
|
||||
"""
|
||||
Возвращает последнюю подписку пользователя.
|
||||
Возвращает список подписок пользователя.
|
||||
"""
|
||||
async for session in self.session_generator():
|
||||
try:
|
||||
@@ -90,12 +90,29 @@ class DatabaseManager:
|
||||
.where(Subscription.user_id == user_id)
|
||||
.order_by(desc(Subscription.created_at))
|
||||
)
|
||||
print(result)
|
||||
return result.scalars().all()
|
||||
except SQLAlchemyError as e:
|
||||
self.logger.error(f"Ошибка при получении последней подписки пользователя {user_id}: {e}")
|
||||
return "ERROR"
|
||||
|
||||
async def last_transaction(self, user_id: int):
|
||||
"""
|
||||
Возвращает список транзакций пользователя.
|
||||
"""
|
||||
async for session in self.session_generator():
|
||||
try:
|
||||
result = await session.execute(
|
||||
select(Transaction)
|
||||
.where(Transaction.user_id == user_id)
|
||||
.order_by(desc(Transaction.created_at))
|
||||
)
|
||||
transactions = result.scalars().all()
|
||||
return transactions
|
||||
except SQLAlchemyError as e:
|
||||
self.logger.error(f"Ошибка при получении транзакций пользователя {user_id}: {e}")
|
||||
return "ERROR"
|
||||
|
||||
|
||||
@staticmethod
|
||||
def generate_string(length):
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user