Skip to content

Commit 93eddec

Browse files
Merge pull request #3 from cinderblockgames/streamline
Simplifying
2 parents 625c4fc + 001a2bb commit 93eddec

File tree

4 files changed

+20
-111
lines changed

4 files changed

+20
-111
lines changed

app/Actions/GetLatestSpeedtestData.php

Lines changed: 0 additions & 31 deletions
This file was deleted.

app/Http/Controllers/SpeedtestController.php

Lines changed: 20 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,23 @@
22

33
namespace App\Http\Controllers;
44

5-
use App\Actions\GetLatestSpeedtestData;
6-
use App\Actions\QueueSpeedtest;
7-
use App\Jobs\SpeedtestJob;
5+
use App\Helpers\SpeedtestHelper;
86
use App\Models\Speedtest;
9-
use Carbon\Carbon;
10-
use Exception;
117
use Illuminate\Http\Request;
128
use Illuminate\Http\JsonResponse;
139

1410
class SpeedtestController extends Controller
1511
{
16-
12+
1713
/**
1814
* Return latest speedtest
1915
*
2016
* @return JsonResponse
2117
*/
2218
public function latest()
2319
{
24-
$data = run(GetLatestSpeedtestData::class);
25-
20+
$data = SpeedtestController::getData();
21+
2622
if ($data['data']) {
2723
return response()->json($data, 200);
2824
} else {
@@ -34,25 +30,27 @@ public function latest()
3430
}
3531

3632
/**
37-
* Queue a new speedtest
33+
* Return latest speedtest
3834
*
39-
* @return JsonResponse
35+
* @return mixed
4036
*/
41-
public function run()
37+
private function getData()
4238
{
43-
try {
44-
run(QueueSpeedtest::class);
39+
$data = SpeedtestHelper::latest();
4540

46-
return response()->json([
47-
'method' => 'run speedtest',
48-
'data' => 'a new speedtest has been added to the queue'
49-
], 200);
50-
} catch (Exception $e) {
51-
return response()->json([
52-
'method' => 'run speedtest',
53-
'error' => $e
54-
], 500);
41+
// Homepage expects this to in Mbps. This calculation matches the results shown in the UI.
42+
if ($data['download']) {
43+
$data['download'] /= 125000;
44+
}
45+
if ($data['upload']) {
46+
$data['upload'] /= 125000;
5547
}
48+
49+
$response = [
50+
'data' => $data,
51+
];
52+
53+
return $response;
5654
}
5755

5856
}

composer.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
"filament/filament": "^2.0",
1313
"filament/spatie-laravel-settings-plugin": "^2.0",
1414
"guzzlehttp/guzzle": "^7.2",
15-
"henrywhitaker3/laravel-actions": "^1.0",
1615
"influxdata/influxdb-client-php": "^2.9",
1716
"laravel-notification-channels/telegram": "^3.0",
1817
"laravel/framework": "^9.19",

composer.lock

Lines changed: 0 additions & 57 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)