fix: badge count uses live query instead of stale cached column, excludes archived

This commit is contained in:
Patrick Britton 2026-02-07 15:15:02 -06:00
parent f48274706a
commit 10c48f1fd7

View file

@ -296,9 +296,10 @@ func (r *NotificationRepository) GetUnreadCount(ctx context.Context, userID stri
func (r *NotificationRepository) GetUnreadBadge(ctx context.Context, userID string) (*models.UnreadBadge, error) {
badge := &models.UnreadBadge{}
// Get notification count
// Get notification count (live query, excludes archived)
err := r.pool.QueryRow(ctx, `
SELECT COALESCE(unread_notification_count, 0) FROM profiles WHERE id = $1::uuid
SELECT COUNT(*) FROM public.notifications
WHERE user_id = $1::uuid AND is_read = FALSE AND archived_at IS NULL
`, userID).Scan(&badge.NotificationCount)
if err != nil {
return nil, err