From c76ffb0fe4dc5edf0b1e71bca24620df7cdc0cc5 Mon Sep 17 00:00:00 2001 From: Neo Date: Sun, 10 Aug 2025 15:25:35 +0900 Subject: [PATCH] chore: adds a check to only query reactions when there are actual memos (#4984) --- server/router/api/v1/memo_service.go | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/server/router/api/v1/memo_service.go b/server/router/api/v1/memo_service.go index 41f6f238c..85ce0748d 100644 --- a/server/router/api/v1/memo_service.go +++ b/server/router/api/v1/memo_service.go @@ -186,15 +186,17 @@ func (s *APIV1Service) ListMemos(ctx context.Context, request *v1pb.ListMemosReq memoNames = append(memoNames, fmt.Sprintf("'%s/%s'", MemoNamePrefix, m.UID)) } - reactions, err := s.Store.ListReactions(ctx, &store.FindReaction{ - Filters: []string{fmt.Sprintf("content_id in [%s]", strings.Join(memoNames, ", "))}, - }) - if err != nil { - return nil, status.Errorf(codes.Internal, "failed to list reactions") - } + if len(memoNames) > 0 { + reactions, err := s.Store.ListReactions(ctx, &store.FindReaction{ + Filters: []string{fmt.Sprintf("content_id in [%s]", strings.Join(memoNames, ", "))}, + }) + if err != nil { + return nil, status.Errorf(codes.Internal, "failed to list reactions") + } - for _, reaction := range reactions { - reactionMap[reaction.ContentID] = append(reactionMap[reaction.ContentID], reaction) + for _, reaction := range reactions { + reactionMap[reaction.ContentID] = append(reactionMap[reaction.ContentID], reaction) + } } for _, memo := range memos {