mirror of
https://github.com/henrywhitaker3/Speedtest-Tracker.git
synced 2025-12-21 13:23:04 +01:00
@@ -4,6 +4,7 @@ namespace App\Helpers;
|
|||||||
|
|
||||||
use App\Events\TestNotificationEvent;
|
use App\Events\TestNotificationEvent;
|
||||||
use App\Setting;
|
use App\Setting;
|
||||||
|
use Cache;
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
|
|
||||||
class SettingsHelper {
|
class SettingsHelper {
|
||||||
@@ -53,6 +54,10 @@ class SettingsHelper {
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if($name == 'show_failed_tests_on_graph') {
|
||||||
|
Cache::flush();
|
||||||
|
}
|
||||||
|
|
||||||
return $setting;
|
return $setting;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -63,6 +63,14 @@ class SpeedtestController extends Controller
|
|||||||
|
|
||||||
$ttl = Carbon::now()->addDays(1);
|
$ttl = Carbon::now()->addDays(1);
|
||||||
$data = Cache::remember('speedtest-days-' . $days, $ttl, function () use ($days) {
|
$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))
|
return Speedtest::where('created_at', '>=', Carbon::now()->subDays($days))
|
||||||
->where('failed', false)
|
->where('failed', false)
|
||||||
->orderBy('created_at', 'asc')
|
->orderBy('created_at', 'asc')
|
||||||
|
|||||||
@@ -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
2
public/js/app.js
vendored
File diff suppressed because one or more lines are too long
4
resources/js/components/Settings/Settings.js
vendored
4
resources/js/components/Settings/Settings.js
vendored
@@ -119,6 +119,10 @@ export default class Settings extends Component {
|
|||||||
'value': 6
|
'value': 6
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
obj: e.show_failed_tests_on_graph,
|
||||||
|
type: 'checkbox'
|
||||||
}
|
}
|
||||||
]} />
|
]} />
|
||||||
</Col>
|
</Col>
|
||||||
|
|||||||
Reference in New Issue
Block a user