This is an automated email from the ASF dual-hosted git repository.

linkinstar pushed a commit to branch dev
in repository https://gitbox.apache.org/repos/asf/incubator-answer.git

commit ae2d4a33aed73b57a492c0656699f41cd3dbdb8c
Author: hgaol <[email protected]>
AuthorDate: Fri May 10 00:15:43 2024 +0800

    count real users and bug fix
---
 internal/service/meta/meta_service.go | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/internal/service/meta/meta_service.go 
b/internal/service/meta/meta_service.go
index 33129015..fa208729 100644
--- a/internal/service/meta/meta_service.go
+++ b/internal/service/meta/meta_service.go
@@ -200,26 +200,26 @@ func (ms *MetaService) convertToReactionResp(ctx 
context.Context, userId string,
        // traverse map and convert to username
        for emoji, userIds := range reaction {
                resp.ReactionSummary[emoji] = &schema.ReactionItem{
-                       Count:    len(userIds),
                        IsActive: isInArray(userIds, userId),
                }
                userNames := make([]string, 0)
                userBasicInfos, err := 
ms.userCommon.BatchUserBasicInfoByID(ctx, userIds)
+               resp.ReactionSummary[emoji].Count = len(userBasicInfos)
                if err != nil {
                        return resp, err
                }
                // get username
                for _, userBasicInfo := range userBasicInfos {
-                       if len(userNames) == 5 {
+                       userNames = append(userNames, userBasicInfo.Username)
+                       if len(userNames) == 5 && len(userBasicInfos) > 5 {
                                resp.ReactionSummary[emoji].Tooltip = 
translator.TrWithData(lang, constant.ReactionTooltipLabel, map[string]string{
-                                       "Count": strconv.Itoa(len(userIds) - 5),
+                                       "Count": 
strconv.Itoa(len(userBasicInfos) - 5),
                                        "Names": strings.Join(userNames, ", "),
                                })
                                break
                        }
-                       userNames = append(userNames, userBasicInfo.Username)
                }
-               if len(userIds) <= 5 {
+               if len(userBasicInfos) <= 5 {
                        resp.ReactionSummary[emoji].Tooltip = 
strings.Join(userNames, ", ")
                }
        }

Reply via email to