mirror of
https://github.com/koloideal/DutyLog.git
synced 2026-08-08 10:01:14 +03:00
sort transactions newest-first in resident and user history; 40 transactions in creator history
This commit is contained in:
@@ -586,8 +586,8 @@ async def get_resident_history_data(
|
|||||||
return {"history_content": "Ошибка: резидент не найден", "transactions": [], "has_transactions": False}
|
return {"history_content": "Ошибка: резидент не найден", "transactions": [], "has_transactions": False}
|
||||||
|
|
||||||
transactions = await transactions_repository.get_resident_history(resident_id)
|
transactions = await transactions_repository.get_resident_history(resident_id)
|
||||||
transactions_sorted = sorted(transactions, key=lambda x: x.created_at)
|
transactions_sorted = sorted(transactions, key=lambda x: x.created_at, reverse=True)
|
||||||
last_10 = transactions_sorted[-10:]
|
last_10 = transactions_sorted[:10]
|
||||||
|
|
||||||
resident_name = resident.real_name if resident.real_name else "Без имени"
|
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}
|
return {"history_content": history_text, "transactions": [], "has_transactions": False}
|
||||||
|
|
||||||
transactions = await transactions_repository.get_resident_history(resident.id)
|
transactions = await transactions_repository.get_resident_history(resident.id)
|
||||||
transactions_sorted = sorted(transactions, key=lambda x: x.created_at)
|
transactions_sorted = sorted(transactions, key=lambda x: x.created_at, reverse=True)
|
||||||
last_10 = transactions_sorted[-10:]
|
last_10 = transactions_sorted[:10]
|
||||||
|
|
||||||
if not last_10:
|
if not last_10:
|
||||||
history_text = "📜 <b>История операций</b>\n\n<b>👤 Ваши операции:</b>\n<i>История операций пуста</i>\n\n"
|
history_text = "📜 <b>История операций</b>\n\n<b>👤 Ваши операции:</b>\n<i>История операций пуста</i>\n\n"
|
||||||
|
|||||||
Reference in New Issue
Block a user