From 10c48f1fd790e4a634b6105e7117e78a9ae522a0 Mon Sep 17 00:00:00 2001 From: Patrick Britton Date: Sat, 7 Feb 2026 15:15:02 -0600 Subject: [PATCH] fix: badge count uses live query instead of stale cached column, excludes archived --- go-backend/internal/repository/notification_repository.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) 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