mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-26 00:03:16 +00:00
Update Profile, fix follower counter bug
This commit is contained in:
parent
76813d351b
commit
d06bec9cd9
1 changed files with 8 additions and 12 deletions
|
@ -65,13 +65,11 @@ class Profile extends Model
|
|||
public function followingCount($short = false)
|
||||
{
|
||||
$count = Cache::remember('profile:following_count:'.$this->id, now()->addMonths(1), function() {
|
||||
$count = $this->following_count;
|
||||
if($count) {
|
||||
return $count;
|
||||
}
|
||||
$count = $this->following()->count();
|
||||
if($this->following_count != $count) {
|
||||
$this->following_count = $count;
|
||||
$this->save();
|
||||
}
|
||||
return $count;
|
||||
});
|
||||
|
||||
|
@ -81,13 +79,11 @@ class Profile extends Model
|
|||
public function followerCount($short = false)
|
||||
{
|
||||
$count = Cache::remember('profile:follower_count:'.$this->id, now()->addMonths(1), function() {
|
||||
$count = $this->followers_count;
|
||||
if($count) {
|
||||
return $count;
|
||||
}
|
||||
$count = $this->followers()->count();
|
||||
if($this->followers_count != $count) {
|
||||
$this->followers_count = $count;
|
||||
$this->save();
|
||||
}
|
||||
return $count;
|
||||
});
|
||||
return $short ? PrettyNumber::convert($count) : $count;
|
||||
|
|
Loading…
Reference in a new issue