Добавлена функция calculate_user_total
This commit is contained in:
+9
-1
@@ -57,4 +57,12 @@ def group_by_user(orders: list[dict]) -> dict[int, list[dict]]:
|
||||
if uid not in grouped:
|
||||
grouped[uid] = []
|
||||
grouped[uid].append(order)
|
||||
return grouped
|
||||
return grouped
|
||||
|
||||
|
||||
# 4. Расчет общей суммы трат пользователя
|
||||
def calculate_user_total(user_orders: list[dict]) -> float:
|
||||
"""
|
||||
Суммирует все значения 'total' для одного пользователя.
|
||||
"""
|
||||
return sum(order['total'] for order in user_orders)
|
||||
Reference in New Issue
Block a user