From 0955c36f6be7abd4b8d64aee560f38b4103fdb2a Mon Sep 17 00:00:00 2001 From: Zichao Lin Date: Fri, 21 Aug 2026 14:44:22 +0800 Subject: [PATCH] =?UTF-8?q?fix(dashboard):=20received=20country=20pie=20ch?= =?UTF-8?q?art=20now=20groups=20by=20country=5Ffrom=20(=E5=AF=84=E5=87=BA?= =?UTF-8?q?=E5=9B=BD)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/routers/web.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/app/routers/web.py b/app/routers/web.py index ac8723a..720a1bf 100644 --- a/app/routers/web.py +++ b/app/routers/web.py @@ -616,12 +616,14 @@ def dashboard(request: Request, user: User = Depends(get_current_user_web), db: sent_country_counts: dict[str, int] = {} received_country_counts: dict[str, int] = {} for c in all_cards: - if not c.country_to: - continue if c.status in ("pending", "sent", "delivered"): + if not c.country_to: + continue sent_country_counts[c.country_to] = sent_country_counts.get(c.country_to, 0) + 1 elif c.status == "received": - received_country_counts[c.country_to] = received_country_counts.get(c.country_to, 0) + 1 + if not c.country_from: + continue + received_country_counts[c.country_from] = received_country_counts.get(c.country_from, 0) + 1 sent_country_stats = sorted(sent_country_counts.items(), key=lambda x: -x[1]) received_country_stats = sorted(received_country_counts.items(), key=lambda x: -x[1])