Added toggle to show failed tests on graph

re #285
This commit is contained in:
Henry Whitaker
2020-08-28 20:31:32 +01:00
parent dd56a667cd
commit ec56337b99
5 changed files with 56 additions and 1 deletions

View File

@@ -4,6 +4,7 @@ namespace App\Helpers;
use App\Events\TestNotificationEvent;
use App\Setting;
use Cache;
use Carbon\Carbon;
class SettingsHelper {
@@ -53,6 +54,10 @@ class SettingsHelper {
]);
}
if($name == 'show_failed_tests_on_graph') {
Cache::flush();
}
return $setting;
}

View File

@@ -63,6 +63,14 @@ class SpeedtestController extends Controller
$ttl = Carbon::now()->addDays(1);
$data = Cache::remember('speedtest-days-' . $days, $ttl, function () use ($days) {
$showFailed = (bool)SettingsHelper::get('show_failed_tests_on_graph')->value;
if($showFailed === true) {
return Speedtest::where('created_at', '>=', Carbon::now()->subDays($days))
->orderBy('created_at', 'asc')
->get();
}
return Speedtest::where('created_at', '>=', Carbon::now()->subDays($days))
->where('failed', false)
->orderBy('created_at', 'asc')

View File

@@ -0,0 +1,38 @@
<?php
use App\Helpers\SettingsHelper;
use App\Setting;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class AddShowFailedTestsSetting extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
if(!SettingsHelper::get('show_failed_tests_on_graph')) {
Setting::create([
'name' => 'show_failed_tests_on_graph',
'value' => true,
'description' => 'If enabled, failed tests will appear on the graphs as 0.'
]);
}
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Setting::whereIn('name', [
'show_failed_tests_on_graph',
])->delete();
}
}

2
public/js/app.js vendored

File diff suppressed because one or more lines are too long

View File

@@ -119,6 +119,10 @@ export default class Settings extends Component {
'value': 6
}
],
},
{
obj: e.show_failed_tests_on_graph,
type: 'checkbox'
}
]} />
</Col>