From d6b6f2e3990f926a954a26fc067c7f6d6050ec5f Mon Sep 17 00:00:00 2001 From: LittleSheep Date: Sun, 13 Oct 2024 19:48:19 +0800 Subject: [PATCH] :bug: Fix counting reactions in batch --- pkg/internal/services/reactions.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/pkg/internal/services/reactions.go b/pkg/internal/services/reactions.go index b37166d..df12ad2 100644 --- a/pkg/internal/services/reactions.go +++ b/pkg/internal/services/reactions.go @@ -49,7 +49,11 @@ func BatchListPostReactions(tx *gorm.DB, indexField string) (map[uint]map[string if _, ok := reactInfo[info.ID]; !ok { reactInfo[info.ID] = make(map[string]int64) } - reactInfo[info.ID][info.Symbol] = info.Count + if _, exists := reactInfo[info.ID][info.Symbol]; exists { + reactInfo[info.ID][info.Symbol] += info.Count + } else { + reactInfo[info.ID][info.Symbol] = info.Count + } } return reactInfo, nil