perf: Enrich calls in combined sql queries

Signed-off-by: Julius Härtl <jus@bitgrid.net>
This commit is contained in:
Julius Härtl
2023-02-15 09:36:51 +01:00
parent 23813b7a03
commit 7bfbbee6e8
4 changed files with 72 additions and 64 deletions

View File

@@ -83,10 +83,7 @@ class SearchService {
$matchedCards = $this->cardMapper->search($boardIds, $this->filterStringParser->parse($term), $limit, $cursor);
$self = $this;
return array_map(function (Card $card) use ($self) {
$self->cardService->enrich($card);
return $card;
}, $matchedCards);
return $this->cardService->enrichCards($matchedCards);
}
public function searchBoards(string $term, ?int $limit, ?int $cursor): array {
@@ -117,7 +114,8 @@ class SearchService {
$comment = $this->commentsManager->get($cardRow['comment_id']);
unset($cardRow['comment_id']);
$card = Card::fromRow($cardRow);
$self->cardService->enrich($card);
// TODO: Only perform one enrich call here
$self->cardService->enrichCards([$card]);
$user = $this->userManager->get($comment->getActorId());
$displayName = $user ? $user->getDisplayName() : '';
return new CommentSearchResultEntry($comment->getId(), $comment->getMessage(), $displayName, $card, $this->urlGenerator, $this->l10n);