Merge pull request #779 from nextcloud/bugfix/778/count-only-Follow

count only 'Follow'
pull/772/head
Maxence Lange 2019-10-03 10:20:28 -01:00 zatwierdzone przez GitHub
commit fa5c1c7597
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
3 zmienionych plików z 11 dodań i 9 usunięć

Wyświetl plik

@ -169,8 +169,9 @@ class FollowsRequest extends FollowsRequestBuilder {
*/
public function countFollowers(string $actorId): int {
$qb = $this->countFollowsSelectSql();
$this->limitToObjectId($qb, $actorId);
$this->limitToAccepted($qb, true);
$qb->limitToObjectId($actorId);
$qb->limitToType(Follow::TYPE);
$qb->limitToAccepted(true);
$cursor = $qb->execute();
$data = $cursor->fetch();
@ -187,8 +188,9 @@ class FollowsRequest extends FollowsRequestBuilder {
*/
public function countFollowing(string $actorId): int {
$qb = $this->countFollowsSelectSql();
$this->limitToActorId($qb, $actorId);
$this->limitToAccepted($qb, true);
$qb->limitToActorId($actorId);
$qb->limitToType(Follow::TYPE);
$qb->limitToAccepted(true);
$cursor = $qb->execute();
$data = $cursor->fetch();

Wyświetl plik

@ -97,10 +97,10 @@ class FollowsRequestBuilder extends CoreRequestBuilder {
/**
* Base of the Sql Select request for Shares
*
* @return IQueryBuilder
* @return SocialQueryBuilder
*/
protected function countFollowsSelectSql(): IQueryBuilder {
$qb = $this->dbConnection->getQueryBuilder();
protected function countFollowsSelectSql(): SocialQueryBuilder {
$qb = $this->getQueryBuilder();
$qb->selectAlias($qb->createFunction('COUNT(*)'), 'count')
->from(self::TABLE_FOLLOWS, 'f');

Wyświetl plik

@ -284,8 +284,8 @@ class AccountService {
*/
public function addLocalActorDetailCount(Person &$actor) {
$count = [
'followers' => $this->followsRequest->countFollowers($actor->getId()) - 1,
'following' => $this->followsRequest->countFollowing($actor->getId()) - 1,
'followers' => $this->followsRequest->countFollowers($actor->getId()),
'following' => $this->followsRequest->countFollowing($actor->getId()),
'post' => $this->streamRequest->countNotesFromActorId($actor->getId())
];
$actor->setDetailArray('count', $count);