mirror of
https://github.com/YunoHost-Apps/pixelfed_ynh.git
synced 2024-09-03 20:06:04 +02: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
|
// TODO: refactor this mess
|
||||||
$owner = Auth::check() && Auth::id() === $user->user_id;
|
$owner = Auth::check() && Auth::id() === $user->user_id;
|
||||||
$following = ($owner == false && Auth::check()) ? $user->followedBy(Auth::user()->profile) : false;
|
$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'));
|
return view('profile.show', compact('user', 'owner', 'following', 'timeline'));
|
||||||
}
|
}
|
||||||
|
|
|
@ -106,10 +106,10 @@
|
||||||
<div class="info-overlay-text">
|
<div class="info-overlay-text">
|
||||||
<h5 class="text-white m-auto font-weight-bold">
|
<h5 class="text-white m-auto font-weight-bold">
|
||||||
<span class="pr-4">
|
<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>
|
<span>
|
||||||
<span class="icon-speech pr-1"></span> {{$status->comments()->count()}}
|
<span class="icon-speech pr-1"></span> {{$status->comments_count}}
|
||||||
</span>
|
</span>
|
||||||
</h5>
|
</h5>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Add table
Reference in a new issue