mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-22 14:31:26 +00:00
Fix n+1 comment + like counts in status overlays
This commit is contained in:
parent
3fcb53c7a6
commit
3d657e0c52
2 changed files with 8 additions and 3 deletions
|
@ -32,7 +32,12 @@ class ProfileController extends Controller
|
|||
// TODO: refactor this mess
|
||||
$owner = Auth::check() && Auth::id() === $user->user_id;
|
||||
$following = ($owner == false && Auth::check()) ? $user->followedBy(Auth::user()->profile) : false;
|
||||
$timeline = $user->statuses()->whereHas('media')->whereNull('in_reply_to_id')->orderBy('id','desc')->paginate(21);
|
||||
$timeline = $user->statuses()
|
||||
->whereHas('media')
|
||||
->whereNull('in_reply_to_id')
|
||||
->orderBy('id','desc')
|
||||
->withCount(['comments', 'likes'])
|
||||
->simplePaginate(21);
|
||||
|
||||
return view('profile.show', compact('user', 'owner', 'following', 'timeline'));
|
||||
}
|
||||
|
|
|
@ -106,10 +106,10 @@
|
|||
<div class="info-overlay-text">
|
||||
<h5 class="text-white m-auto font-weight-bold">
|
||||
<span class="pr-4">
|
||||
<span class="icon-heart pr-1"></span> {{$status->likes()->count()}}
|
||||
<span class="icon-heart pr-1"></span> {{$status->likes_count}}
|
||||
</span>
|
||||
<span>
|
||||
<span class="icon-speech pr-1"></span> {{$status->comments()->count()}}
|
||||
<span class="icon-speech pr-1"></span> {{$status->comments_count}}
|
||||
</span>
|
||||
</h5>
|
||||
</div>
|
||||
|
|
Loading…
Reference in a new issue