From ab9c6c85bb7ea1d38cd8074be9623be2ae145d16 Mon Sep 17 00:00:00 2001 From: tokumeikoi Date: Fri, 26 Feb 2021 23:54:38 +0900 Subject: [PATCH] fix: server rank --- app/Http/Controllers/Admin/StatController.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/app/Http/Controllers/Admin/StatController.php b/app/Http/Controllers/Admin/StatController.php index 21e91d8e..286e2ace 100644 --- a/app/Http/Controllers/Admin/StatController.php +++ b/app/Http/Controllers/Admin/StatController.php @@ -99,12 +99,13 @@ class StatController extends Controller 'server_id', 'server_type', 'u', - 'd' + 'd', + DB::raw('(u+d) as total') ]) ->where('record_at', '>=', $timestamp) ->where('record_type', 'd') ->limit(10) - ->orderBy('record_at', 'DESC') + ->orderBy('total', 'DESC') ->get() ->toArray(); foreach ($statistics as $k => $v) { @@ -113,7 +114,7 @@ class StatController extends Controller $statistics[$k]['server_name'] = $server['name']; } } - $statistics[$k]['total'] = ($v['u'] + $v['d']) / 1073741824; + $statistics[$k]['total'] = $statistics[$k]['total'] / 1073741824; } array_multisort(array_column($statistics, 'total'), SORT_DESC, $statistics); return response([