zoomcal-jeffemmett/backlog/tasks/task-9 - Fix-event_count-in...

38 lines
1.0 KiB
Markdown

---
id: task-9
title: Fix event_count in sources API
status: Done
assignee: []
created_date: '2026-01-02 14:30'
updated_date: '2026-01-02 17:10'
labels: [backend]
dependencies: []
priority: medium
---
## Description
<!-- SECTION:DESCRIPTION:BEGIN -->
The event_count field shows 0 for all sources - need to update the sync command or serializer to compute correct counts
<!-- SECTION:DESCRIPTION:END -->
## Resolution
**No fix needed** - the backend already correctly computes `event_count`.
The serializer in `/opt/apps/pkmn/calendar_hub/serializers.py` already has:
```python
def get_event_count(self, obj):
return obj.events.count()
```
And the UnifiedEvent model has `related_name='events'` on the source FK.
Verified the API returns correct counts:
- jeffemmett@gmail.com: 1,955 events
- jeff@block.science: 888 events
- jessica.zartler@gmail.com: 859 events
- givethdotio@gmail.com: 663 events
The initial "0 for all sources" was because no events had been synced yet. After running `sync_google_to_unified`, the counts are correct.