Moved API run call to queue

Now doesn't take like 60 seconds to run a speedtest from the API. Leaving it standard in the artisan command
This commit is contained in:
Henry Whitaker
2020-04-08 14:03:41 +01:00
parent 0062ac6960
commit 53823c1ed7
3 changed files with 44 additions and 4 deletions

View File

@@ -3,6 +3,7 @@
namespace App\Http\Controllers;
use App\Helpers\SpeedtestHelper;
use App\Jobs\SpeedtestJob;
use Exception;
use Illuminate\Http\Request;
@@ -28,10 +29,10 @@ class SpeedtestController extends Controller
public function run()
{
try {
$data = SpeedtestHelper::runSpeedtest();
$data = SpeedtestJob::dispatch();
return response()->json([
'method' => 'run speedtest',
'data' => $data
'data' => 'a new speedtest has been added to the queue'
], 200);
} catch(Exception $e) {
return response()->json([