perf: remove duplicate fetching of assignments
Signed-off-by: Julius Härtl <jus@bitgrid.net>
This commit is contained in:
@@ -148,8 +148,8 @@ class CardService {
|
|||||||
$cardLabels = array_filter($assignedLabels, function (Label $label) use ($card) {
|
$cardLabels = array_filter($assignedLabels, function (Label $label) use ($card) {
|
||||||
return $label->getCardId() === $card->getId();
|
return $label->getCardId() === $card->getId();
|
||||||
});
|
});
|
||||||
$cardAssignedUsers = array_filter($assignedUsers, function (Assignment $label) use ($card) {
|
$cardAssignedUsers = array_filter($assignedUsers, function (Assignment $assignment) use ($card) {
|
||||||
return $label->getCardId() === $card->getId();
|
return $assignment->getCardId() === $card->getId();
|
||||||
});
|
});
|
||||||
$card->setLabels($cardLabels);
|
$card->setLabels($cardLabels);
|
||||||
$card->setAssignedUsers($cardAssignedUsers);
|
$card->setAssignedUsers($cardAssignedUsers);
|
||||||
@@ -175,16 +175,17 @@ class CardService {
|
|||||||
public function find(int $cardId) {
|
public function find(int $cardId) {
|
||||||
$this->permissionService->checkPermission($this->cardMapper, $cardId, Acl::PERMISSION_READ);
|
$this->permissionService->checkPermission($this->cardMapper, $cardId, Acl::PERMISSION_READ);
|
||||||
$card = $this->cardMapper->find($cardId);
|
$card = $this->cardMapper->find($cardId);
|
||||||
$assignedUsers = $this->assignedUsersMapper->findAll($card->getId());
|
$this->enrichCards([$card]);
|
||||||
|
|
||||||
|
// Attachments are only enriched on individual card fetching
|
||||||
$attachments = $this->attachmentService->findAll($cardId, true);
|
$attachments = $this->attachmentService->findAll($cardId, true);
|
||||||
if ($this->request->getParam('apiVersion') === '1.0') {
|
if ($this->request->getParam('apiVersion') === '1.0') {
|
||||||
$attachments = array_filter($attachments, function ($attachment) {
|
$attachments = array_filter($attachments, function ($attachment) {
|
||||||
return $attachment->getType() === 'deck_file';
|
return $attachment->getType() === 'deck_file';
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
$card->setAssignedUsers($assignedUsers);
|
|
||||||
$card->setAttachments($attachments);
|
$card->setAttachments($attachments);
|
||||||
$this->enrichCards([$card]);
|
|
||||||
return $card;
|
return $card;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -82,7 +82,6 @@ class SearchService {
|
|||||||
}, $boards);
|
}, $boards);
|
||||||
$matchedCards = $this->cardMapper->search($boardIds, $this->filterStringParser->parse($term), $limit, $cursor);
|
$matchedCards = $this->cardMapper->search($boardIds, $this->filterStringParser->parse($term), $limit, $cursor);
|
||||||
|
|
||||||
$self = $this;
|
|
||||||
return $this->cardService->enrichCards($matchedCards);
|
return $this->cardService->enrichCards($matchedCards);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user