perf: Add mapper methods to get multiple labels/assignments for cards
Signed-off-by: Julius Härtl <jus@bitgrid.net>
This commit is contained in:
@@ -60,7 +60,19 @@ class AssignmentMapper extends QBMapper implements IPermissionMapper {
|
||||
$qb = $this->db->getQueryBuilder();
|
||||
$qb->select('*')
|
||||
->from('deck_assigned_users')
|
||||
->where($qb->expr()->eq('card_id', $qb->createNamedParameter($cardId, PDO::PARAM_INT)));
|
||||
->where($qb->expr()->eq('card_id', $qb->createNamedParameter($cardId, IQueryBuilder::PARAM_INT)));
|
||||
$users = $this->findEntities($qb);
|
||||
foreach ($users as $user) {
|
||||
$this->mapParticipant($user);
|
||||
}
|
||||
return $users;
|
||||
}
|
||||
|
||||
public function findIn(array $cardIds): array {
|
||||
$qb = $this->db->getQueryBuilder();
|
||||
$qb->select('*')
|
||||
->from('deck_assigned_users')
|
||||
->where($qb->expr()->in('card_id', $qb->createNamedParameter($cardIds, IQueryBuilder::PARAM_INT_ARRAY)));
|
||||
$users = $this->findEntities($qb);
|
||||
foreach ($users as $user) {
|
||||
$this->mapParticipant($user);
|
||||
|
||||
@@ -79,6 +79,19 @@ class LabelMapper extends DeckMapper implements IPermissionMapper {
|
||||
return $this->findEntities($qb);
|
||||
}
|
||||
|
||||
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 $this->findEntities($qb);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param numeric $boardId
|
||||
* @param int|null $limit
|
||||
|
||||
Reference in New Issue
Block a user