kopia lustrzana https://github.com/nextcloud/social
count only 'Follow'
Signed-off-by: Maxence Lange <maxence@artificial-owl.com>pull/779/head
rodzic
c0d71b7e09
commit
729b10e5df
|
@ -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();
|
||||
|
|
|
@ -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');
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
Ładowanie…
Reference in New Issue