mirror of https://github.com/pixelfed/pixelfed.git
Fix n+1 query in status view
This commit is contained in:
parent
7f7e8526f3
commit
6d5c8fb90a
|
@ -13,7 +13,9 @@ class StatusController extends Controller
|
||||||
public function show(Request $request, $username, int $id)
|
public function show(Request $request, $username, int $id)
|
||||||
{
|
{
|
||||||
$user = Profile::whereUsername($username)->firstOrFail();
|
$user = Profile::whereUsername($username)->firstOrFail();
|
||||||
$status = Status::whereProfileId($user->id)->findOrFail($id);
|
$status = Status::whereProfileId($user->id)
|
||||||
|
->withCount('likes')
|
||||||
|
->findOrFail($id);
|
||||||
if(!$status->media_path && $status->in_reply_to_id) {
|
if(!$status->media_path && $status->in_reply_to_id) {
|
||||||
return view('status.reply', compact('user', 'status'));
|
return view('status.reply', compact('user', 'status'));
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,7 +65,7 @@
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="likes font-weight-bold mb-0">
|
<div class="likes font-weight-bold mb-0">
|
||||||
<span class="like-count">{{$status->likes()->count()}}</span> likes
|
<span class="like-count">{{$status->likes_count}}</span> likes
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="card-footer">
|
<div class="card-footer">
|
||||||
|
|
Loading…
Reference in New Issue