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

pull/4992/head
Neo 2 months ago committed by GitHub
parent 1dd25634fd
commit c76ffb0fe4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -186,6 +186,7 @@ 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))
} }
if len(memoNames) > 0 {
reactions, err := s.Store.ListReactions(ctx, &store.FindReaction{ reactions, err := s.Store.ListReactions(ctx, &store.FindReaction{
Filters: []string{fmt.Sprintf("content_id in [%s]", strings.Join(memoNames, ", "))}, Filters: []string{fmt.Sprintf("content_id in [%s]", strings.Join(memoNames, ", "))},
}) })
@ -196,6 +197,7 @@ func (s *APIV1Service) ListMemos(ctx context.Context, request *v1pb.ListMemosReq
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 {
name := fmt.Sprintf("'%s/%s'", MemoNamePrefix, memo.UID) name := fmt.Sprintf("'%s/%s'", MemoNamePrefix, memo.UID)

Loading…
Cancel
Save