add - summary total sharings of brokers on dashboard
This commit is contained in:
@@ -130,7 +130,19 @@ class TransactionDashboardService:
|
|||||||
key=lambda x: -x["total_price"]
|
key=lambda x: -x["total_price"]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# calculate total statistic of every broker
|
||||||
|
share_totals = defaultdict(lambda: {"total_price": 0, "count": 0})
|
||||||
|
|
||||||
|
for product in products_stats:
|
||||||
|
for item in product["item_share_stats"]:
|
||||||
|
name = item["name"]
|
||||||
|
share_totals[name]["total_price"] += item["total_price"]
|
||||||
|
share_totals[name]["count"] += item["count"]
|
||||||
|
|
||||||
|
share_totals = dict(share_totals)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"transaction_summary": transaction_stats,
|
"transaction_summary": transaction_stats,
|
||||||
"product_summary": list(products_stats),
|
"product_summary": list(products_stats),
|
||||||
|
"brokers_sharing_summary": share_totals
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user