Merge pull request #2901 from pixelfed/staging

Update Profile, fix following count bug
This commit is contained in:
daniel 2021-09-04 03:19:06 -06:00 committed by GitHub
commit 945568da6a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 4 deletions

View file

@ -105,6 +105,7 @@
- Updated Timeline, remove recent posts. ([7641b731](https://github.com/pixelfed/pixelfed/commit/7641b731)) - Updated Timeline, remove recent posts. ([7641b731](https://github.com/pixelfed/pixelfed/commit/7641b731))
- Updated InstanceCrawlPipeline, remove unused variable. ([e73cf531](https://github.com/pixelfed/pixelfed/commit/e73cf531)) - Updated InstanceCrawlPipeline, remove unused variable. ([e73cf531](https://github.com/pixelfed/pixelfed/commit/e73cf531))
- Updated StoryComposeController, fix expiry bug. ([7dee8f58](https://github.com/pixelfed/pixelfed/commit/7dee8f58)) - Updated StoryComposeController, fix expiry bug. ([7dee8f58](https://github.com/pixelfed/pixelfed/commit/7dee8f58))
- Updated Profile, fix following count bug. ([ee9f0795](https://github.com/pixelfed/pixelfed/commit/ee9f0795))
- ([](https://github.com/pixelfed/pixelfed/commit/)) - ([](https://github.com/pixelfed/pixelfed/commit/))
## [v0.11.0 (2021-06-01)](https://github.com/pixelfed/pixelfed/compare/v0.10.10...v0.11.0) ## [v0.11.0 (2021-06-01)](https://github.com/pixelfed/pixelfed/compare/v0.10.10...v0.11.0)

View file

@ -65,11 +65,11 @@ class Profile extends Model
public function followingCount($short = false) public function followingCount($short = false)
{ {
$count = Cache::remember('profile:following_count:'.$this->id, now()->addMonths(1), function() { $count = Cache::remember('profile:following_count:v1:'.$this->id, now()->addMonths(1), function() {
if($this->domain == null && $this->user->settings->show_profile_following_count == false) { if($this->domain == null && $this->user->settings->show_profile_following_count == false) {
return 0; return 0;
} }
$count = DB::table('followers')->select('following_id')->where('following_id', $this->id)->count(); $count = DB::table('followers')->where('profile_id', $this->id)->count();
if($this->following_count != $count) { if($this->following_count != $count) {
$this->following_count = $count; $this->following_count = $count;
$this->save(); $this->save();
@ -82,11 +82,11 @@ class Profile extends Model
public function followerCount($short = false) public function followerCount($short = false)
{ {
$count = Cache::remember('profile:follower_count:'.$this->id, now()->addMonths(1), function() { $count = Cache::remember('profile:follower_count:v1:'.$this->id, now()->addMonths(1), function() {
if($this->domain == null && $this->user->settings->show_profile_follower_count == false) { if($this->domain == null && $this->user->settings->show_profile_follower_count == false) {
return 0; return 0;
} }
$count = $this->followers()->count(); $count = DB::table('followers')->where('following_id', $this->id)->count();
if($this->followers_count != $count) { if($this->followers_count != $count) {
$this->followers_count = $count; $this->followers_count = $count;
$this->save(); $this->save();