diff --git a/lib/Command/CirclesList.php b/lib/Command/CirclesList.php index 6dcc36fe3..c8b8a95aa 100644 --- a/lib/Command/CirclesList.php +++ b/lib/Command/CirclesList.php @@ -54,6 +54,7 @@ use OCA\Circles\Model\Circle; use OCA\Circles\Model\Member; use OCA\Circles\Model\ModelManager; +use OCA\Circles\Model\Probes\BasicProbe; use OCA\Circles\Model\Probes\CircleProbe; use OCA\Circles\Service\CircleService; use OCA\Circles\Service\ConfigService; @@ -190,7 +191,8 @@ protected function execute(InputInterface $input, OutputInterface $output): int $probe = new CircleProbe(); $probe->filterHiddenCircles() - ->filterBackendCircles(); + ->filterBackendCircles() + ->addDetail(BasicProbe::DETAILS_POPULATION); if ($input->getOption('system')) { $probe->includeSystemCircles(); diff --git a/lib/Controller/AdminController.php b/lib/Controller/AdminController.php index 65c743e4a..7aa2e6205 100644 --- a/lib/Controller/AdminController.php +++ b/lib/Controller/AdminController.php @@ -44,6 +44,7 @@ use OCA\Circles\Exceptions\SingleCircleNotFoundException; use OCA\Circles\Model\FederatedUser; use OCA\Circles\Model\Member; +use OCA\Circles\Model\Probes\BasicProbe; use OCA\Circles\Model\Probes\CircleProbe; use OCA\Circles\Service\CircleService; use OCA\Circles\Service\ConfigService; @@ -270,7 +271,8 @@ public function circles(string $emulated): DataResponse { $probe = new CircleProbe(); $probe->filterHiddenCircles() - ->filterBackendCircles(); + ->filterBackendCircles() + ->addDetail(BasicProbe::DETAILS_POPULATION); return new DataResponse($this->serializeArray($this->circleService->getCircles($probe))); } catch (Exception $e) { diff --git a/lib/Controller/LocalController.php b/lib/Controller/LocalController.php index 1e42119f9..fee96cacb 100644 --- a/lib/Controller/LocalController.php +++ b/lib/Controller/LocalController.php @@ -42,6 +42,7 @@ use OCA\Circles\Exceptions\SingleCircleNotFoundException; use OCA\Circles\Model\FederatedUser; use OCA\Circles\Model\Member; +use OCA\Circles\Model\Probes\BasicProbe; use OCA\Circles\Model\Probes\CircleProbe; use OCA\Circles\Service\CircleService; use OCA\Circles\Service\ConfigService; @@ -419,7 +420,8 @@ public function circles(): DataResponse { $probe = new CircleProbe(); $probe->filterHiddenCircles() - ->filterBackendCircles(); + ->filterBackendCircles() + ->addDetail(BasicProbe::DETAILS_POPULATION); return new DataResponse($this->serializeArray($this->circleService->getCircles($probe))); } catch (Exception $e) { diff --git a/lib/Controller/RemoteController.php b/lib/Controller/RemoteController.php index a1cabb253..f04159cc4 100644 --- a/lib/Controller/RemoteController.php +++ b/lib/Controller/RemoteController.php @@ -56,6 +56,7 @@ use OCA\Circles\Model\Federated\RemoteInstance; use OCA\Circles\Model\FederatedUser; use OCA\Circles\Model\Member; +use OCA\Circles\Model\Probes\BasicProbe; use OCA\Circles\Model\Probes\CircleProbe; use OCA\Circles\Service\CircleService; use OCA\Circles\Service\ConfigService; @@ -267,7 +268,8 @@ public function circles(): DataResponse { $probe = new CircleProbe(); $probe->setFilterCircle($filterCircle) - ->setFilterMember($filterMember); + ->setFilterMember($filterMember) + ->addDetail(BasicProbe::DETAILS_POPULATION); $circles = $this->circleService->getCircles($probe); diff --git a/lib/Db/CircleRequest.php b/lib/Db/CircleRequest.php index 1f694ce5d..e3fef6ad3 100644 --- a/lib/Db/CircleRequest.php +++ b/lib/Db/CircleRequest.php @@ -41,6 +41,7 @@ use OCA\Circles\Model\Circle; use OCA\Circles\Model\FederatedUser; use OCA\Circles\Model\Member; +use OCA\Circles\Model\Probes\BasicProbe; use OCA\Circles\Model\Probes\CircleProbe; /** @@ -184,7 +185,10 @@ public function getCircles(?IFederatedUser $initiator, CircleProbe $probe): arra $qb->limitToRemoteInstance(CoreQueryBuilder::CIRCLE, $probe->getFilterRemoteInstance(), false); } - $qb->countMembers(CoreQueryBuilder::CIRCLE); + if ($probe->showDetail(BasicProbe::DETAILS_POPULATION)) { + $qb->countMembers(CoreQueryBuilder::CIRCLE); + } + $qb->chunk($probe->getItemsOffset(), $probe->getItemsLimit()); return $this->getItemsFromRequest($qb); @@ -258,7 +262,10 @@ public function getCircle( if ($probe->hasFilterRemoteInstance()) { $qb->limitToRemoteInstance(CoreQueryBuilder::CIRCLE, $probe->getFilterRemoteInstance(), false); } - $qb->countMembers(CoreQueryBuilder::CIRCLE); + + if ($probe->showDetail(BasicProbe::DETAILS_POPULATION)) { + $qb->countMembers(CoreQueryBuilder::CIRCLE); + } return $this->getItemFromRequest($qb); } @@ -356,7 +363,8 @@ public function searchCircle(Circle $circle, ?IFederatedUser $initiator = null): if (!is_null($initiator)) { $qb->setOptions( - [CoreQueryBuilder::CIRCLE], [ + [CoreQueryBuilder::CIRCLE], + [ 'getData' => true, 'initiatorDirectMember' => true ] diff --git a/lib/Db/CoreQueryBuilder.php b/lib/Db/CoreQueryBuilder.php index 06f1085f3..f1f5f04ca 100644 --- a/lib/Db/CoreQueryBuilder.php +++ b/lib/Db/CoreQueryBuilder.php @@ -709,11 +709,6 @@ public function countMembers(string $alias): void { return; } - $getData = $this->getBool('getData', $options, false); - if (!$getData) { - return; - } - $expr = $this->expr(); $this->selectAlias( $this->createFunction('COUNT(`' . $aliasMemberCount . '`.`member_id`)'), diff --git a/lib/IQueryProbe.php b/lib/IQueryProbe.php index 971a89e5c..108b2634a 100644 --- a/lib/IQueryProbe.php +++ b/lib/IQueryProbe.php @@ -59,11 +59,11 @@ public function getItemsLimit(): int; public function getDetails(): int; /** - * @param int $details + * @param int $detail * * @return bool */ - public function showDetails(int $details): bool; + public function showDetail(int $detail): bool; /** * @return Circle diff --git a/lib/Model/Probes/BasicProbe.php b/lib/Model/Probes/BasicProbe.php index ee6a95dab..082883607 100644 --- a/lib/Model/Probes/BasicProbe.php +++ b/lib/Model/Probes/BasicProbe.php @@ -43,7 +43,8 @@ */ class BasicProbe implements IQueryProbe { public const DETAILS_NONE = 0; - public const DETAILS_ALL = 64; + public const DETAILS_POPULATION = 32; + public const DETAILS_ALL = 127; /** @var int */ @@ -122,14 +123,24 @@ public function getDetails(): int { return $this->details; } + /** + * @param int $detail + * + * @return $this + */ + public function addDetail(int $detail): self { + $this->details |= $detail; + + return $this; + } /** - * @param int $details + * @param int $detail * * @return bool */ - public function showDetails(int $details): bool { - return (($this->getDetails() & $details) !== 0); + public function showDetail(int $detail): bool { + return (($this->getDetails() & $detail) !== 0); } diff --git a/lib/Service/MigrationService.php b/lib/Service/MigrationService.php index bf684f38d..e70e01ed3 100644 --- a/lib/Service/MigrationService.php +++ b/lib/Service/MigrationService.php @@ -450,11 +450,6 @@ private function generateMemberFrom21(SimpleDataStore $data): Member { $member->setSingleId($singleMember->getSingleId()); -// "cached_update":"2021-05-02 12:13:22", -// "joined":"2021-05-02 12:13:22", -// "contact_checked":null," -// "circle_source":null} - return $member; }