feat(dashboard): add pending as separate stat card and progress bar segment

This commit is contained in:
2026-07-28 07:46:42 +08:00
parent 64adbba302
commit 12de30d91f
3 changed files with 18 additions and 4 deletions
+6 -4
View File
@@ -593,7 +593,8 @@ def dashboard(request: Request, user: User = Depends(get_current_user_web), db:
all_cards.extend(cards)
total = len(all_cards)
sent = sum(1 for c in all_cards if c.status in ("pending", "sent"))
pending = sum(1 for c in all_cards if c.status == "pending")
sent = sum(1 for c in all_cards if c.status == "sent")
delivered = sum(1 for c in all_cards if c.status == "delivered")
received = sum(1 for c in all_cards if c.status == "received")
countries = len({c.country_to for c in all_cards if c.country_to})
@@ -604,11 +605,12 @@ def dashboard(request: Request, user: User = Depends(get_current_user_web), db:
# status distribution for progress bar
if total > 0:
pending_pct = round(pending / total * 100)
sent_pct = round(sent / total * 100)
delivered_pct = round(delivered / total * 100)
received_pct = round(received / total * 100)
else:
sent_pct = delivered_pct = received_pct = 0
pending_pct = sent_pct = delivered_pct = received_pct = 0
# country stats split by sent/received
sent_country_counts: dict[str, int] = {}
@@ -626,9 +628,9 @@ def dashboard(request: Request, user: User = Depends(get_current_user_web), db:
from datetime import datetime, timezone as _tz
return _render(request, "dashboard.html", {"user": user, "profiles": profiles,
"total": total, "sent": sent, "delivered": delivered, "received": received,
"total": total, "pending": pending, "sent": sent, "delivered": delivered, "received": received,
"countries": countries, "recent": recent,
"sent_pct": sent_pct, "delivered_pct": delivered_pct, "received_pct": received_pct,
"pending_pct": pending_pct, "sent_pct": sent_pct, "delivered_pct": delivered_pct, "received_pct": received_pct,
"sent_country_stats": sent_country_stats, "received_country_stats": received_country_stats,
"now": datetime.now(_tz.utc) + timedelta(hours=8),
})