From 8ceec962245f3744915dad88860607539464eec1 Mon Sep 17 00:00:00 2001 From: printempw Date: Thu, 22 Feb 2018 19:17:40 +0800 Subject: [PATCH] Optimize SQL queries on view admin.index --- resources/views/admin/index.tpl | 121 +++++++++++++------------------- 1 file changed, 50 insertions(+), 71 deletions(-) diff --git a/resources/views/admin/index.tpl b/resources/views/admin/index.tpl index 4669ace2..54fb45d6 100644 --- a/resources/views/admin/index.tpl +++ b/resources/views/admin/index.tpl @@ -25,7 +25,7 @@
{{ trans('admin.index.total-users') }} - {{ App\Models\User::all()->count() }} + {{ App\Models\User::count() }}
@@ -37,7 +37,7 @@
{{ trans('admin.index.total-players') }} - {{ App\Models\Player::all()->count() }} + {{ App\Models\Player::count() }}
@@ -48,7 +48,7 @@
{{ trans('admin.index.total-textures') }} - {{ \Database::table('textures')->getRecordNum() }} + {{ App\Models\Texture::count() }}
@@ -56,7 +56,7 @@
{{ trans('admin.index.disk-usage') }} - fetchArray("SELECT SUM(`size`) AS total_size FROM `{table}` WHERE 1")['total_size'] ?: 0; ?> + sum('size') ?: 0; ?> {{ $size > 1024 ? round($size / 1024, 1)."MB" : $size."KB" }}
@@ -83,97 +83,76 @@ - @endsection @section('script') -