fix: Profile, optimize SQL query for uploads count

This commit is contained in:
Oha-you
2021-04-29 20:20:04 +03:00
parent 249eb1c1ef
commit efcb5db45b
2 changed files with 5 additions and 1 deletions
+4
View File
@@ -56,7 +56,10 @@ class UserController extends Controller
$groups = Group::all();
$followers = Follow::where('target_id', '=', $user->id)->latest()->limit(25)->get();
$uploaded = Torrent::where('user_id', '=', $user->id)->count();
$history = $user->history;
$warnings = Warning::where('user_id', '=', $user->id)->whereNotNull('torrent')->where('active', '=', 1)->take(\config('hitrun.max_warnings'))->get();
$hitrun = Warning::where('user_id', '=', $user->id)->latest()->paginate(10);
@@ -82,6 +85,7 @@ class UserController extends Controller
'user' => $user,
'groups' => $groups,
'followers' => $followers,
'uploaded' => $uploaded,
'history' => $history,
'warnings' => $warnings,
'hitrun' => $hitrun,
+1 -1
View File
@@ -140,7 +140,7 @@
<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">{{ $uploaded }}</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>