From 94b3e90dafe91b080943bf3e332977c221d68e58 Mon Sep 17 00:00:00 2001 From: Maciej Pienczyn Date: Thu, 19 Feb 2026 14:17:02 +0100 Subject: [PATCH] feat: show attendee count next to upcoming events on dashboard Batch-query confirmed attendee counts per event and display as subtle cyan number with people icon in event meta line. Co-Authored-By: Claude Opus 4.6 --- blueprints/public/routes.py | 12 +++++++++++- templates/dashboard.html | 4 ++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/blueprints/public/routes.py b/blueprints/public/routes.py index 972bd6f..fd87232 100644 --- a/blueprints/public/routes.py +++ b/blueprints/public/routes.py @@ -677,8 +677,9 @@ def dashboard(): NordaEvent.event_date >= date.today() ).order_by(NordaEvent.event_date.asc()).limit(3).all() - # Batch RSVP lookup for current user + # Batch RSVP lookup for current user + attendee counts user_event_ids = set() + event_attendee_counts = {} if upcoming_events: event_ids = [e.id for e in upcoming_events] rsvps = db.query(EventAttendee.event_id).filter( @@ -688,6 +689,14 @@ def dashboard(): ).all() user_event_ids = {r[0] for r in rsvps} + # Count confirmed attendees per event + from sqlalchemy import func + counts = db.query(EventAttendee.event_id, func.count(EventAttendee.id)).filter( + EventAttendee.event_id.in_(event_ids), + EventAttendee.status == 'confirmed' + ).group_by(EventAttendee.event_id).all() + event_attendee_counts = {eid: cnt for eid, cnt in counts} + # Widget 2: Recent announcements (3 latest published, pinned first, not expired) recent_announcements = db.query(Announcement).filter( Announcement.status == 'published', @@ -725,6 +734,7 @@ def dashboard(): user_forum_topics_count=user_forum_topics_count, upcoming_events=upcoming_events, user_event_ids=user_event_ids, + event_attendee_counts=event_attendee_counts, recent_announcements=recent_announcements, recent_forum_topics=recent_forum_topics, recent_classifieds=recent_classifieds, diff --git a/templates/dashboard.html b/templates/dashboard.html index 41cdf03..c640c8c 100755 --- a/templates/dashboard.html +++ b/templates/dashboard.html @@ -945,6 +945,10 @@ {{ event.event_date.strftime('%d.%m.%Y') }} {% if event.time_start %} o {{ event.time_start.strftime('%H:%M') }}{% endif %} {% if event.location %} · {{ event.location[:30] }}{% endif %} + {% if event_attendee_counts.get(event.id, 0) > 0 %} + · {{ event_attendee_counts[event.id] }} + + {% endif %}