diff --git a/go-backend/internal/repository/notification_repository.go b/go-backend/internal/repository/notification_repository.go index c43afaa..065a7fd 100644 --- a/go-backend/internal/repository/notification_repository.go +++ b/go-backend/internal/repository/notification_repository.go @@ -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