Skip to content

Commit

Permalink
Use defined speedtest server (#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexjustesen authored Sep 13, 2022
1 parent c3e3233 commit bf78bbd
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
8 changes: 7 additions & 1 deletion app/Console/Commands/RunSpeedtest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,13 @@ class RunSpeedtest extends Command
*/
public function handle()
{
ExecSpeedtest::dispatch();
$speedtest = [];

if ($this->argument('server')) {
$speedtest = array_merge($speedtest, ['ookla_server_id' => $this->argument('server')]);
}

ExecSpeedtest::dispatch(speedtest: $speedtest);

$this->info('✅ added manual speedtest to the queue');

Expand Down
14 changes: 13 additions & 1 deletion app/Jobs/ExecSpeedtest.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,19 @@ public function __construct(
*/
public function handle()
{
$process = new Process(['speedtest', '--accept-license', '--format=json']);
$args = [
'speedtest',
'--accept-license',
'--format=json',
];

if (! blank($this->speedtest)) {
if (! blank($this->speedtest['ookla_server_id'])) {
$args = array_merge($args, ['--server-id='.$this->speedtest['ookla_server_id']]);
}
}

$process = new Process($args);
$process->run();

if (! $process->isSuccessful()) {
Expand Down

0 comments on commit bf78bbd

Please sign in to comment.