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])