From 93cdedb6b0043ac815364d6fd9fae9a76e8cdcb6 Mon Sep 17 00:00:00 2001 From: Julius Knorr Date: Thu, 19 Dec 2024 18:04:42 +0100 Subject: [PATCH] Revert "fix: Chunk query for getting labels for cards" This reverts commit cb469fb78cc5ded413c12d29c24554462c83f175. --- lib/Db/LabelMapper.php | 36 ++++++++++++++++-------------------- 1 file changed, 16 insertions(+), 20 deletions(-) diff --git a/lib/Db/LabelMapper.php b/lib/Db/LabelMapper.php index fabd9bab6..f0b32413c 100644 --- a/lib/Db/LabelMapper.php +++ b/lib/Db/LabelMapper.php @@ -44,40 +44,36 @@ class LabelMapper extends DeckMapper implements IPermissionMapper { } /** + * @param numeric $cardId + * @param int|null $limit + * @param int|null $offset * @return Label[] * @throws \OCP\DB\Exception */ - public function findAssignedLabelsForCard(int $cardId): array { + public function findAssignedLabelsForCard($cardId, $limit = null, $offset = null): array { $qb = $this->db->getQueryBuilder(); $qb->select('l.*', 'card_id') ->from($this->getTableName(), 'l') ->innerJoin('l', 'deck_assigned_labels', 'al', 'l.id = al.label_id') ->where($qb->expr()->eq('card_id', $qb->createNamedParameter($cardId, IQueryBuilder::PARAM_INT))) - ->orderBy('l.id'); - - return $this->findEntities($qb); - } - - public function findAssignedLabelsForCards(array $cardIds, ?int $limit = null, ?int $offset = null): array { - $qb = $this->db->getQueryBuilder(); - $qb->select('l.*', 'card_id') - ->from($this->getTableName(), 'l') - ->innerJoin('l', 'deck_assigned_labels', 'al', 'l.id = al.label_id') - ->where($qb->expr()->in('card_id', $qb->createParameter('ids'))) ->orderBy('l.id') ->setMaxResults($limit) ->setFirstResult($offset); - $results = []; - foreach (array_chunk($cardIds, 1000) as $chunk) { - $qb->setParameter('ids', $chunk, IQueryBuilder::PARAM_STR_ARRAY); + return $this->findEntities($qb); + } - foreach ($this->findEntities($qb) as $result) { - $results[] = $result; - } - } + public function findAssignedLabelsForCards($cardIds, $limit = null, $offset = null): array { + $qb = $this->db->getQueryBuilder(); + $qb->select('l.*', 'card_id') + ->from($this->getTableName(), 'l') + ->innerJoin('l', 'deck_assigned_labels', 'al', 'l.id = al.label_id') + ->where($qb->expr()->in('card_id', $qb->createNamedParameter($cardIds, IQueryBuilder::PARAM_INT_ARRAY))) + ->orderBy('l.id') + ->setMaxResults($limit) + ->setFirstResult($offset); - return $results; + return $this->findEntities($qb); } /**