chore: adds a check to only query reactions when there are actual memos (#4984)

This commit is contained in:
Neo 2025-08-10 15:25:35 +09:00 committed by GitHub
parent 1dd25634fd
commit c76ffb0fe4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 10 additions and 8 deletions

View File

@ -186,15 +186,17 @@ func (s *APIV1Service) ListMemos(ctx context.Context, request *v1pb.ListMemosReq
memoNames = append(memoNames, fmt.Sprintf("'%s/%s'", MemoNamePrefix, m.UID)) memoNames = append(memoNames, fmt.Sprintf("'%s/%s'", MemoNamePrefix, m.UID))
} }
reactions, err := s.Store.ListReactions(ctx, &store.FindReaction{ if len(memoNames) > 0 {
Filters: []string{fmt.Sprintf("content_id in [%s]", strings.Join(memoNames, ", "))}, 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 err != nil {
} return nil, status.Errorf(codes.Internal, "failed to list reactions")
}
for _, reaction := range reactions { for _, reaction := range reactions {
reactionMap[reaction.ContentID] = append(reactionMap[reaction.ContentID], reaction) reactionMap[reaction.ContentID] = append(reactionMap[reaction.ContentID], reaction)
}
} }
for _, memo := range memos { for _, memo := range memos {