sort transactions newest-first in resident and user history; 40 transactions in creator history

This commit is contained in:
2026-07-15 01:34:33 +03:00
parent 061c9c9ad6
commit 78930ab920
2 changed files with 4 additions and 4 deletions
@@ -586,8 +586,8 @@ async def get_resident_history_data(
return {"history_content": "Ошибка: резидент не найден", "transactions": [], "has_transactions": False}
transactions = await transactions_repository.get_resident_history(resident_id)
transactions_sorted = sorted(transactions, key=lambda x: x.created_at)
last_10 = transactions_sorted[-10:]
transactions_sorted = sorted(transactions, key=lambda x: x.created_at, reverse=True)
last_10 = transactions_sorted[:10]
resident_name = resident.real_name if resident.real_name else "Без имени"
@@ -41,8 +41,8 @@ async def get_history_data(
return {"history_content": history_text, "transactions": [], "has_transactions": False}
transactions = await transactions_repository.get_resident_history(resident.id)
transactions_sorted = sorted(transactions, key=lambda x: x.created_at)
last_10 = transactions_sorted[-10:]
transactions_sorted = sorted(transactions, key=lambda x: x.created_at, reverse=True)
last_10 = transactions_sorted[:10]
if not last_10:
history_text = "📜 <b>История операций</b>\n\n<b>👤 Ваши операции:</b>\n<i>История операций пуста</i>\n\n"