Merge pull request #3996 from nextcloud/backport/3982/stable23

[stable23] Improve CalDAV integration performance
This commit is contained in:
Raul Ferreira Fuentes
2022-08-25 12:13:49 +00:00
committed by GitHub
2 changed files with 18 additions and 9 deletions

View File

@@ -52,12 +52,6 @@ class Calendar extends ExternalCalendar {
$this->board = $board;
$this->principalUri = $principalUri;
if ($board) {
$this->children = $this->backend->getChildren($board->getId());
} else {
$this->children = [];
}
}
public function getOwner() {
@@ -122,7 +116,7 @@ class Calendar extends ExternalCalendar {
public function getChild($name) {
if ($this->childExists($name)) {
$card = array_values(array_filter(
$this->children,
$this->getBackendChildren(),
function ($card) use (&$name) {
return $card->getCalendarPrefix() . '-' . $card->getId() . '.ics' === $name;
}
@@ -137,7 +131,7 @@ class Calendar extends ExternalCalendar {
public function getChildren() {
$childNames = array_map(function ($card) {
return $card->getCalendarPrefix() . '-' . $card->getId() . '.ics';
}, $this->children);
}, $this->getBackendChildren());
$children = [];
@@ -148,9 +142,23 @@ class Calendar extends ExternalCalendar {
return $children;
}
private function getBackendChildren() {
if ($this->children) {
return $this->children;
}
if ($this->board) {
$this->children = $this->backend->getChildren($this->board->getId());
} else {
$this->children = [];
}
return $this->children;
}
public function childExists($name) {
return count(array_filter(
$this->children,
$this->getBackendChildren(),
function ($card) use (&$name) {
return $card->getCalendarPrefix() . '-' . $card->getId() . '.ics' === $name;
}

View File

@@ -193,6 +193,7 @@ class CardMapper extends QBMapper implements IPermissionMapper {
->from('deck_cards', 'c')
->join('c', 'deck_stacks', 's', 's.id = c.stack_id')
->where($qb->expr()->eq('s.board_id', $qb->createNamedParameter($boardId)))
->andWhere($qb->expr()->eq('c.archived', $qb->createNamedParameter(false, IQueryBuilder::PARAM_BOOL)))
->andWhere($qb->expr()->eq('c.deleted_at', $qb->createNamedParameter('0')))
->orderBy('c.duedate')
->setMaxResults($limit)