mirror of
https://github.com/alexjustesen/speedtest-tracker.git
synced 2026-06-23 04:20:08 +00:00
28418c3761
Co-authored-by: Alex Justesen <1144087+alexjustesen@users.noreply.github.com>
47 lines
1.4 KiB
PHP
47 lines
1.4 KiB
PHP
<?php
|
|
|
|
namespace App\Actions\Librespeed;
|
|
|
|
use App\Enums\ResultService;
|
|
use App\Enums\ResultStatus;
|
|
use App\Events\SpeedtestWaiting;
|
|
use App\Models\Result;
|
|
use Lorisleiva\Actions\Concerns\AsAction;
|
|
use Throwable;
|
|
|
|
class RunSpeedtest
|
|
{
|
|
use AsAction;
|
|
|
|
public function handle(bool $isScheduled = false, ?string $server = null, ?int $dispatchedBy = null): mixed
|
|
{
|
|
$result = Result::create([
|
|
'data->server->url' => $server,
|
|
'service' => ResultService::Librespeed,
|
|
'status' => ResultStatus::Waiting,
|
|
'scheduled' => $isScheduled,
|
|
'dispatched_by' => $dispatchedBy,
|
|
]);
|
|
|
|
SpeedtestWaiting::dispatch($result);
|
|
|
|
// TODO: Implement Librespeed speedtest job batching
|
|
|
|
// Bus::batch([
|
|
// [
|
|
// new StartSpeedtestJob($result),
|
|
// new CheckForInternetConnectionJob($result),
|
|
// new SkipSpeedtestJob($result),
|
|
// new SelectSpeedtestServerJob($result),
|
|
// new RunSpeedtestJob($result),
|
|
// new BenchmarkSpeedtestJob($result),
|
|
// new CompleteSpeedtestJob($result),
|
|
// ],
|
|
// ])->catch(function (Batch $batch, ?Throwable $e) {
|
|
// Log::error(sprintf('Speedtest batch "%s" failed for an unknown reason.', $batch->id));
|
|
// })->name('Ookla Speedtest')->dispatch();
|
|
|
|
return $result;
|
|
}
|
|
}
|