feat: show attendee count next to upcoming events on dashboard
Some checks are pending
NordaBiz Tests / Unit & Integration Tests (push) Waiting to run
NordaBiz Tests / E2E Tests (Playwright) (push) Blocked by required conditions
NordaBiz Tests / Smoke Tests (Production) (push) Blocked by required conditions
NordaBiz Tests / Send Failure Notification (push) Blocked by required conditions
Some checks are pending
NordaBiz Tests / Unit & Integration Tests (push) Waiting to run
NordaBiz Tests / E2E Tests (Playwright) (push) Blocked by required conditions
NordaBiz Tests / Smoke Tests (Production) (push) Blocked by required conditions
NordaBiz Tests / Send Failure Notification (push) Blocked by required conditions
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 <noreply@anthropic.com>
This commit is contained in:
parent
846adf665d
commit
94b3e90daf
@ -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,
|
||||
|
||||
@ -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 %}
|
||||
· <span style="color: #0891b2;">{{ event_attendee_counts[event.id] }}
|
||||
<svg width="12" height="12" fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24" style="vertical-align: -1px;"><path d="M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2"/><circle cx="9" cy="7" r="4"/><path d="M23 21v-2a4 4 0 0 0-3-3.87m-4-12a4 4 0 0 1 0 7.75"/></svg></span>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user