Compare commits

...

3 Commits

Author SHA1 Message Date
Carl Schwan
8ebeeaa755 perf: Use getBoard to get the board
So that this can benefit from a local cache

Signed-off-by: Carl Schwan <carl.schwan@nextclound.com>
2025-08-13 16:51:40 +02:00
Carl Schwan
ce81c89b03 perf: Only enrich with labels when no labels was prefetched
Signed-off-by: Carl Schwan <carl.schwan@nextclound.com>
2025-08-13 13:32:17 +02:00
Carl Schwan
1e59511d8d perf: Don't call twice the same query
Find entities will execute the query already, there is no need to do it
twice.

Signed-off-by: Carl Schwan <carl.schwan@nextclound.com>
2025-08-13 13:31:41 +02:00
4 changed files with 8 additions and 8 deletions

View File

@@ -45,8 +45,7 @@ class SessionMapper extends QBMapper {
$qb->select('id', 'board_id', 'last_contact', 'user_id', 'token')
->from($this->getTableName())
->where($qb->expr()->eq('board_id', $qb->createNamedParameter($boardId)))
->andWhere($qb->expr()->gt('last_contact', $qb->createNamedParameter(time() - SessionService::SESSION_VALID_TIME)))
->executeQuery();
->andWhere($qb->expr()->gt('last_contact', $qb->createNamedParameter(time() - SessionService::SESSION_VALID_TIME)));
return $this->findEntities($qb);
}

View File

@@ -621,7 +621,9 @@ class BoardService {
if ($fullDetails) {
$this->enrichWithStacks($board);
$this->enrichWithLabels($board);
if ($board->getLabels() === null) {
$this->enrichWithLabels($board);
}
$this->enrichWithUsers($board);
$this->enrichWithBoardSettings($board);
$this->enrichWithActiveSessions($board);

View File

@@ -214,7 +214,7 @@ class PermissionService {
}
try {
$board = $this->boardMapper->find($boardId);
$board = $this->getBoard($boardId);
} catch (DoesNotExistException $e) {
return [];
} catch (MultipleObjectsReturnedException $e) {
@@ -227,7 +227,7 @@ class PermissionService {
} else {
$users[$board->getOwner()] = new User($board->getOwner(), $this->userManager);
}
$acls = $this->aclMapper->findAll($boardId);
$acls = $board->getAcl();
/** @var Acl $acl */
foreach ($acls as $acl) {
if ($acl->getType() === Acl::PERMISSION_TYPE_USER) {

View File

@@ -347,9 +347,8 @@ class PermissionServiceTest extends \Test\TestCase {
->method('__call')
->with('getOwner', [])
->willReturn('user1');
$this->aclMapper->expects($this->once())
->method('findAll')
->with(123)
$board->expects($this->any())
->method('getAcl')
->willReturn([$aclUser, $aclGroup]);
$this->boardMapper->expects($this->once())
->method('find')