fix: badge count uses live query instead of stale cached column, excludes archived
This commit is contained in:
parent
f48274706a
commit
10c48f1fd7
|
|
@ -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) {
|
func (r *NotificationRepository) GetUnreadBadge(ctx context.Context, userID string) (*models.UnreadBadge, error) {
|
||||||
badge := &models.UnreadBadge{}
|
badge := &models.UnreadBadge{}
|
||||||
|
|
||||||
// Get notification count
|
// Get notification count (live query, excludes archived)
|
||||||
err := r.pool.QueryRow(ctx, `
|
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)
|
`, userID).Scan(&badge.NotificationCount)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue