diff --git a/app/Enums/ResultStatus.php b/app/Enums/ResultStatus.php index 5e13d7326..d93dc34b5 100644 --- a/app/Enums/ResultStatus.php +++ b/app/Enums/ResultStatus.php @@ -8,16 +8,20 @@ enum ResultStatus: string implements HasColor, HasLabel { + case Checking = 'checking'; case Completed = 'completed'; case Failed = 'failed'; + case Running = 'running'; case Started = 'started'; case Skipped = 'skipped'; public function getColor(): ?string { return match ($this) { + self::Checking => 'info', self::Completed => 'success', self::Failed => 'danger', + self::Running => 'info', self::Started => 'info', self::Skipped => 'gray', }; diff --git a/app/Events/SpeedtestChecking.php b/app/Events/SpeedtestChecking.php new file mode 100644 index 000000000..894bba95f --- /dev/null +++ b/app/Events/SpeedtestChecking.php @@ -0,0 +1,20 @@ +result->update([ + 'status' => ResultStatus::Checking, + ]); + + SpeedtestChecking::dispatch($this->result); + if (GetExternalIpAddress::run() !== false) { return; } diff --git a/app/Jobs/Ookla/RunSpeedtestJob.php b/app/Jobs/Ookla/RunSpeedtestJob.php index 3fda9e9d3..b285fd531 100644 --- a/app/Jobs/Ookla/RunSpeedtestJob.php +++ b/app/Jobs/Ookla/RunSpeedtestJob.php @@ -5,6 +5,7 @@ use App\Enums\ResultStatus; use App\Events\SpeedtestCompleted; use App\Events\SpeedtestFailed; +use App\Events\SpeedtestRunning; use App\Helpers\Ookla; use App\Models\Result; use Illuminate\Bus\Batchable; @@ -41,6 +42,12 @@ public function handle(): void return; } + $this->result->update([ + 'status' => ResultStatus::Running, + ]); + + SpeedtestRunning::dispatch($this->result); + $command = array_filter([ 'speedtest', '--accept-license',