fix: server rank

This commit is contained in:
tokumeikoi 2021-02-26 23:54:38 +09:00
parent 0e6f6358d8
commit ab9c6c85bb

View File

@ -99,12 +99,13 @@ class StatController extends Controller
'server_id', 'server_id',
'server_type', 'server_type',
'u', 'u',
'd' 'd',
DB::raw('(u+d) as total')
]) ])
->where('record_at', '>=', $timestamp) ->where('record_at', '>=', $timestamp)
->where('record_type', 'd') ->where('record_type', 'd')
->limit(10) ->limit(10)
->orderBy('record_at', 'DESC') ->orderBy('total', 'DESC')
->get() ->get()
->toArray(); ->toArray();
foreach ($statistics as $k => $v) { foreach ($statistics as $k => $v) {
@ -113,7 +114,7 @@ class StatController extends Controller
$statistics[$k]['server_name'] = $server['name']; $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); array_multisort(array_column($statistics, 'total'), SORT_DESC, $statistics);
return response([ return response([