Skip to content

Commit

Permalink
Merge pull request #1746 from Oha-you/bug/profile
Browse files Browse the repository at this point in the history
(Fix) Profile: optimize SQL query for uploads count
  • Loading branch information
HDVinnie authored Apr 29, 2021
2 parents c38af62 + faaccbb commit 5b2e269
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion app/Http/Controllers/UserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class UserController extends Controller
*/
public function show($username)
{
$user = User::with(['privacy', 'history'])->where('username', '=', $username)->firstOrFail();
$user = User::with(['privacy', 'history'])->withCount('torrents')->where('username', '=', $username)->firstOrFail();

$groups = Group::all();
$followers = Follow::where('target_id', '=', $user->id)->latest()->limit(25)->get();
Expand Down
2 changes: 1 addition & 1 deletion resources/views/user/profile.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ class="{{ config('other.font-awesome') }} fa-trash"></span> @lang('user.delete')
<div class="text-center">
<span class="badge-user badge-float p-10"><i
class="{{ config('other.font-awesome') }} fa-upload"></i> @lang('user.total-uploads')
: <span class="text-green text-bold">{{ $user->torrents->count() }}</span></span>
: <span class="text-green text-bold">{{ $user->torrents_count }}</span></span>
<span class="badge-user badge-float p-10"><i
class="{{ config('other.font-awesome') }} fa-download"></i> @lang('user.total-downloads')
: <span class="text-red text-bold">{{ $history->where('actual_downloaded', '>', 0)->count() }}</span></span>
Expand Down

0 comments on commit 5b2e269

Please sign in to comment.