diff --git a/README.md b/README.md index 136e602e..0b2f6fb6 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Speedtest Tracker -[](https://hub.docker.com/r/henrywhitaker3/speedtest-tracker) [](https://github.com/henrywhitaker3/Speedtest-Tracker/commits) [](https://github.com/henrywhitaker3/Speedtest-Tracker/issues) [](https://github.com/henrywhitaker3/Speedtest-Tracker/commits)  [](https://github.com/henrywhitaker3/Speedtest-Tracker/blob/master/LICENSE) +[](https://hub.docker.com/r/henrywhitaker3/speedtest-tracker) [](https://github.com/henrywhitaker3/Speedtest-Tracker/commits) [](https://github.com/henrywhitaker3/Speedtest-Tracker/issues) [](https://github.com/henrywhitaker3/Speedtest-Tracker/commits)  [](https://github.com/henrywhitaker3/Speedtest-Tracker/blob/master/LICENSE) This program runs a speedtest check every hour and graphs the results. The back-end is written in [Laravel](https://laravel.com/) and the front-end uses [React](https://reactjs.org/). It uses the [Ookla's speedtest cli](https://www.speedtest.net/apps/cli) package to get the data and uses [Chart.js](https://www.chartjs.org/) to plot the results. diff --git a/app/Console/Commands/SpeedtestCommand.php b/app/Console/Commands/SpeedtestCommand.php index 2b914989..cf1dc1ae 100644 --- a/app/Console/Commands/SpeedtestCommand.php +++ b/app/Console/Commands/SpeedtestCommand.php @@ -40,7 +40,7 @@ class SpeedtestCommand extends Command { $this->info('Running speedtest, this might take a while...'); - $results = SpeedtestHelper::runSpeedtest(); + $results = SpeedtestHelper::runSpeedtest(false, false); if(!is_object($results)) { $this->error('Something went wrong running the speedtest.'); diff --git a/app/Helpers/SpeedtestHelper.php b/app/Helpers/SpeedtestHelper.php index e35a1cb9..fc3e0f6c 100644 --- a/app/Helpers/SpeedtestHelper.php +++ b/app/Helpers/SpeedtestHelper.php @@ -17,7 +17,7 @@ class SpeedtestHelper { * @param boolean|string $output If false, new speedtest runs. If anything else, will try to parse as JSON for speedtest results. * @return \App\Speedtest|boolean */ - public static function runSpeedtest($output = false) + public static function runSpeedtest($output = false, $scheduled = true) { if($output === false) { $output = SpeedtestHelper::output(); @@ -38,6 +38,7 @@ class SpeedtestHelper { 'server_name' => $output['server']['name'], 'server_host' => $output['server']['host'] . ':' . $output['server']['port'], 'url' => $output['result']['url'], + 'scheduled' => $scheduled ]); } catch(JsonException $e) { Log::error('Failed to parse speedtest JSON'); diff --git a/app/Http/Controllers/SpeedtestController.php b/app/Http/Controllers/SpeedtestController.php index 41bab815..d1633a93 100644 --- a/app/Http/Controllers/SpeedtestController.php +++ b/app/Http/Controllers/SpeedtestController.php @@ -98,7 +98,7 @@ class SpeedtestController extends Controller public function run() { try { - $data = SpeedtestJob::dispatch(); + $data = SpeedtestJob::dispatch(false); return response()->json([ 'method' => 'run speedtest', 'data' => 'a new speedtest has been added to the queue' diff --git a/app/Jobs/SpeedtestJob.php b/app/Jobs/SpeedtestJob.php index ecae55ef..a34b91c6 100644 --- a/app/Jobs/SpeedtestJob.php +++ b/app/Jobs/SpeedtestJob.php @@ -14,14 +14,16 @@ class SpeedtestJob implements ShouldQueue { use Dispatchable, InteractsWithQueue, Queueable, SerializesModels; + private $scheduled; + /** * Create a new job instance. * * @return void */ - public function __construct() + public function __construct($scheduled = true) { - // + $this->scheduled = $scheduled; } /** @@ -32,7 +34,7 @@ class SpeedtestJob implements ShouldQueue public function handle() { $output = SpeedtestHelper::output(); - $speedtest = SpeedtestHelper::runSpeedtest($output); + $speedtest = SpeedtestHelper::runSpeedtest($output, $this->scheduled); event(new SpeedtestCompleteEvent($speedtest)); return $speedtest; } diff --git a/app/Speedtest.php b/app/Speedtest.php index f6503148..8e5ecfb7 100644 --- a/app/Speedtest.php +++ b/app/Speedtest.php @@ -20,6 +20,7 @@ class Speedtest extends Model 'server_name', 'server_host', 'url', + 'scheduled', ]; protected $table = 'speedtests'; diff --git a/changelog.json b/changelog.json index 9bceca5b..c8b74416 100644 --- a/changelog.json +++ b/changelog.json @@ -1,4 +1,14 @@ { + "1.7.2": [ + { + "description": "Updated UI for speedtest info", + "link": "" + }, + { + "description": "Added field to track manual vs scheduled tests", + "link": "" + } + ], "1.7.1": [ { "description": "Updated dependencies", diff --git a/config/speedtest.php b/config/speedtest.php index 083436f6..c417b256 100644 --- a/config/speedtest.php +++ b/config/speedtest.php @@ -7,7 +7,7 @@ return [ |-------------------------------------------------------------------------- */ - 'version' => '1.7.1', + 'version' => '1.7.2', /* |-------------------------------------------------------------------------- diff --git a/database/migrations/2020_06_28_235331_update_speedtests_add_manual_column.php b/database/migrations/2020_06_28_235331_update_speedtests_add_manual_column.php new file mode 100644 index 00000000..68db1e3e --- /dev/null +++ b/database/migrations/2020_06_28_235331_update_speedtests_add_manual_column.php @@ -0,0 +1,32 @@ +boolean('scheduled')->nullable(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('speedtests', function($table) { + $table->dropColumn('scheduled'); + }); + } +} diff --git a/resources/js/components/Graphics/TableRow.js b/resources/js/components/Graphics/TableRow.js index e23c9316..4bb324d1 100644 --- a/resources/js/components/Graphics/TableRow.js +++ b/resources/js/components/Graphics/TableRow.js @@ -47,7 +47,10 @@ export default class TableRow extends Component {
Server ID: {e.server_id}
Name: {e.server_name}
Host: {e.server_host}
- Speedtest.net +URL: Speedtest.net
+ {e.scheduled != undefined && +Type: {e.scheduled == true ? 'scheduled' : 'manual'}
+ }