[UI] Subtract self follow from total user follows

This commit is contained in:
Hugo Sales 2020-09-05 02:34:01 +00:00 committed by Hugo Sales
parent 6e11143b79
commit 51a398f27a
Signed by: someonewithpc
GPG Key ID: 7D0C7EAFC9D835A0

View File

@ -1,6 +1,7 @@
<?php <?php
// {{{ License // {{{ License
// This file is part of GNU social - https://www.gnu.org/software/social // This file is part of GNU social - https://www.gnu.org/software/social
// //
// GNU social is free software: you can redistribute it and/or modify // GNU social is free software: you can redistribute it and/or modify
@ -15,6 +16,7 @@
// //
// You should have received a copy of the GNU Affero General Public License // You should have received a copy of the GNU Affero General Public License
// along with GNU social. If not, see <http://www.gnu.org/licenses/>. // along with GNU social. If not, see <http://www.gnu.org/licenses/>.
// }}} // }}}
namespace App\Entity; namespace App\Entity;
@ -253,7 +255,7 @@ class GSActor extends Entity
return Cache::get('followers-' . $this->id, return Cache::get('followers-' . $this->id,
function () { function () {
return DB::dql('select count(f) from App\Entity\Follow f where f.followed = :followed', return DB::dql('select count(f) from App\Entity\Follow f where f.followed = :followed',
['followed' => $this->id])[0][1]; ['followed' => $this->id])[0][1] - 1; // Remove self follow
}); });
} }
@ -262,7 +264,7 @@ class GSActor extends Entity
return Cache::get('followed-' . $this->id, return Cache::get('followed-' . $this->id,
function () { function () {
return DB::dql('select count(f) from App\Entity\Follow f where f.follower = :follower', return DB::dql('select count(f) from App\Entity\Follow f where f.follower = :follower',
['follower' => $this->id])[0][1]; ['follower' => $this->id])[0][1] - 1; // Remove self follow
}); });
} }