Updated latest endpoint to ignore failed tests in averages

This commit is contained in:
Henry Whitaker
2020-07-03 12:47:08 +01:00
parent 04d8f729b9
commit 4c7d9b2730

View File

@@ -71,8 +71,10 @@ class SpeedtestController extends Controller
{ {
$data = SpeedtestHelper::latest(); $data = SpeedtestHelper::latest();
$avg = Speedtest::select(DB::raw('AVG(ping) as ping, AVG(download) as download, AVG(upload) as upload')) $avg = Speedtest::select(DB::raw('AVG(ping) as ping, AVG(download) as download, AVG(upload) as upload'))
->where('failed', false)
->get(); ->get();
$max = Speedtest::select(DB::raw('MAX(ping) as ping, MAX(download) as download, MAX(upload) as upload')) $max = Speedtest::select(DB::raw('MAX(ping) as ping, MAX(download) as download, MAX(upload) as upload'))
->where('failed', false)
->get(); ->get();
if($data) { if($data) {