diff --git a/app/Http/Controllers/SpeedtestController.php b/app/Http/Controllers/SpeedtestController.php index f8dec6e2..22dd7394 100644 --- a/app/Http/Controllers/SpeedtestController.php +++ b/app/Http/Controllers/SpeedtestController.php @@ -8,6 +8,7 @@ use App\Speedtest; use Carbon\Carbon; use Exception; use Illuminate\Http\Request; +use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\Validator; class SpeedtestController extends Controller @@ -51,11 +52,17 @@ class SpeedtestController extends Controller public function latest() { $data = SpeedtestHelper::latest(); + $avg = Speedtest::select(DB::raw('AVG(ping) as ping, AVG(download) as download, AVG(upload) as upload')) + ->get(); + $max = Speedtest::select(DB::raw('MAX(ping) as ping, MAX(download) as download, MAX(upload) as upload')) + ->get(); if($data) { return response()->json([ 'method' => 'get latest speedtest', - 'data' => $data + 'data' => $data, + 'average' => $avg[0], + 'max' => $max[0], ], 200); } else { return response()->json([ diff --git a/changelog.json b/changelog.json index 423df79d..2edc640f 100644 --- a/changelog.json +++ b/changelog.json @@ -1,4 +1,10 @@ { + "1.2.5": [ + { + "description": "Added max and average values to the latest results cards.", + "link": "" + } + ], "1.2.4": [ { "description": "Set radius of chart point to 0 so a graph with lots of data looks less cluttered.", diff --git a/config/speedtest.php b/config/speedtest.php index 2c45a30b..4575cbae 100644 --- a/config/speedtest.php +++ b/config/speedtest.php @@ -7,7 +7,7 @@ return [ |-------------------------------------------------------------------------- */ - 'version' => '1.2.4', + 'version' => '1.2.5', /* |--------------------------------------------------------------------------