mirror of
https://github.com/nextcloud/server.git
synced 2026-05-28 04:32:30 -04:00
perf(caldav): Only prefetch published properties
Signed-off-by: Carl Schwan <carl.schwan@nextclound.com>
This commit is contained in:
parent
46f0c6ebb5
commit
9df79bae10
2 changed files with 12 additions and 3 deletions
|
|
@ -383,7 +383,7 @@ class CustomPropertiesBackend implements BackendInterface {
|
|||
$this->userCache = array_merge($this->userCache, $propsByPath);
|
||||
}
|
||||
|
||||
private function cacheCalendars(CalendarHome $node): void {
|
||||
private function cacheCalendars(CalendarHome $node, array $requestedProperties): void {
|
||||
$calendars = $node->getChildren();
|
||||
|
||||
$users = [];
|
||||
|
|
@ -421,6 +421,10 @@ class CustomPropertiesBackend implements BackendInterface {
|
|||
$this->userCache = array_merge($this->userCache, $propsByPath);
|
||||
|
||||
// published properties
|
||||
$allowedProps = array_intersect(self::PUBLISHED_READ_ONLY_PROPERTIES, $requestedProperties);
|
||||
if (empty($allowedProps)) {
|
||||
return;
|
||||
}
|
||||
$paths = [];
|
||||
foreach ($users as $nestedPaths) {
|
||||
$paths = array_merge($paths, $nestedPaths);
|
||||
|
|
@ -428,7 +432,7 @@ class CustomPropertiesBackend implements BackendInterface {
|
|||
$paths = array_unique($paths);
|
||||
|
||||
$propsByPath = array_fill_keys(array_values($paths), []);
|
||||
$properties = $this->propertyMapper->findPropertiesByPaths($paths);
|
||||
$properties = $this->propertyMapper->findPropertiesByPaths($paths, $allowedProps);
|
||||
foreach ($properties as $property) {
|
||||
$propsByPath[$property->getPropertypath()][$property->getPropertyname()] = $this->decodeValueFromDatabase($property->getPropertyvalue(), $property->getValuetype());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -63,15 +63,20 @@ class PropertyMapper extends QBMapper {
|
|||
|
||||
/**
|
||||
* @param string[] $calendars
|
||||
* @param string[] $allowedProperties
|
||||
* @return Property[]
|
||||
* @throws \OCP\DB\Exception
|
||||
*/
|
||||
public function findPropertiesByPaths(array $calendars): array {
|
||||
public function findPropertiesByPaths(array $calendars, array $allowedProperties = []): array {
|
||||
$selectQb = $this->db->getQueryBuilder();
|
||||
$selectQb->select('*')
|
||||
->from(self::TABLE_NAME)
|
||||
->where($selectQb->expr()->in('propertypath', $selectQb->createNamedParameter($calendars, IQueryBuilder::PARAM_STR_ARRAY)));
|
||||
|
||||
if ($allowedProperties) {
|
||||
$selectQb->andWhere($selectQb->expr()->in('propertyname', $selectQb->createNamedParameter($allowedProperties, IQueryBuilder::PARAM_STR_ARRAY)));
|
||||
}
|
||||
|
||||
return $this->findEntities($selectQb);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue