summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorMaxence Lange <maxence@artificial-owl.com>2019-10-02 15:40:38 -0100
committerMaxence Lange <maxence@artificial-owl.com>2019-10-02 15:40:38 -0100
commit729b10e5df9e01df009e1782726f1042a3aea6b9 (patch)
tree1ad58508ee2d5074fa0471ef118f78b96e396395 /lib
parentc0d71b7e096b31b16c7c3446bd32bd8e059b927a (diff)
count only 'Follow'
Signed-off-by: Maxence Lange <maxence@artificial-owl.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/Db/FollowsRequest.php10
-rw-r--r--lib/Db/FollowsRequestBuilder.php6
-rw-r--r--lib/Service/AccountService.php4
3 files changed, 11 insertions, 9 deletions
diff --git a/lib/Db/FollowsRequest.php b/lib/Db/FollowsRequest.php
index cf2b19d3..ec46401f 100644
--- a/lib/Db/FollowsRequest.php
+++ b/lib/Db/FollowsRequest.php
@@ -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();
diff --git a/lib/Db/FollowsRequestBuilder.php b/lib/Db/FollowsRequestBuilder.php
index a41e7114..550dd278 100644
--- a/lib/Db/FollowsRequestBuilder.php
+++ b/lib/Db/FollowsRequestBuilder.php
@@ -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');
diff --git a/lib/Service/AccountService.php b/lib/Service/AccountService.php
index 94b7bce0..70ce2714 100644
--- a/lib/Service/AccountService.php
+++ b/lib/Service/AccountService.php
@@ -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);