fix: Stats返回值语法修复
This commit is contained in:
parent
190df56118
commit
9956ed3f61
|
|
@ -399,17 +399,13 @@ def get_stats(
|
||||||
"bySpecialMark": [{"mark": m, "count": n} for m, n in by_special_mark],
|
"bySpecialMark": [{"mark": m, "count": n} for m, n in by_special_mark],
|
||||||
"byNumberCategory": [{"numberCategory": n, "count": c} for n, c in by_number_category],
|
"byNumberCategory": [{"numberCategory": n, "count": c} for n, c in by_number_category],
|
||||||
# 盈亏统计
|
# 盈亏统计
|
||||||
profit_count = db.query(func.count(Collection.f99_90_id)).filter(
|
|
||||||
sold_filter, Collection.f05_42_goal_price > Collection.f05_40_cost_price
|
|
||||||
).scalar() or 0
|
|
||||||
|
|
||||||
loss_count = db.query(func.count(Collection.f99_90_id)).filter(
|
|
||||||
sold_filter, Collection.f05_42_goal_price <= Collection.f05_40_cost_price
|
|
||||||
).scalar() or 0
|
|
||||||
|
|
||||||
"byProfitLoss": [
|
"byProfitLoss": [
|
||||||
{"type": "profit", "label": "盈利", "count": profit_count},
|
{"type": "profit", "label": "盈利", "count": db.query(func.count(Collection.f99_90_id)).filter(
|
||||||
{"type": "loss", "label": "亏损", "count": loss_count}
|
sold_filter, Collection.f05_42_goal_price > Collection.f05_40_cost_price
|
||||||
|
).scalar() or 0},
|
||||||
|
{"type": "loss", "label": "亏损", "count": db.query(func.count(Collection.f99_90_id)).filter(
|
||||||
|
sold_filter, Collection.f05_42_goal_price <= Collection.f05_40_cost_price
|
||||||
|
).scalar() or 0}
|
||||||
],
|
],
|
||||||
"totalCost": cost_result,
|
"totalCost": cost_result,
|
||||||
"totalTarget": target_result,
|
"totalTarget": target_result,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue