count only 'Follow'

Signed-off-by: Maxence Lange <maxence@artificial-owl.com>
pull/779/head
Maxence Lange 2019-10-02 15:40:38 -01:00
rodzic c0d71b7e09
commit 729b10e5df
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);