Skip to content

Commit 86f2e84

Browse files
authored
Some cleanup (alexjustesen#18)
1 parent cc12e4c commit 86f2e84

File tree

13 files changed

+145
-262
lines changed

13 files changed

+145
-262
lines changed

.dockerignore

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,22 @@
1+
/.idea
2+
/.vscode
3+
/docker/8.1
14
/node_modules
25
/public/build
36
/public/hot
47
/public/storage
58
/storage/*.key
9+
/storage/logs
610
/vendor
7-
config.yml
11+
_ide_helper.php
812
.env
913
.env.backup
14+
.phpstorm.meta.php
1015
.phpunit.result.cache
16+
config.yml
17+
auth.json
18+
docker-compose.yml
1119
Homestead.json
1220
Homestead.yaml
13-
auth.json
1421
npm-debug.log
1522
yarn-error.log
16-
/.idea
17-
/.vscode

.env.example

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ DB_PASSWORD=
1818
BROADCAST_DRIVER=log
1919
CACHE_DRIVER=file
2020
FILESYSTEM_DISK=local
21-
QUEUE_CONNECTION=sync
21+
QUEUE_CONNECTION=database
2222
SESSION_DRIVER=file
2323
SESSION_LIFETIME=120
2424

README.md

Lines changed: 3 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -4,82 +4,8 @@ Welcome to Speedtest Tracker! Speedtest Tracker runs a speedtest check against O
44

55
This project replaces https://github.com/henrywhitaker3/Speedtest-Tracker as it looks like this project has been abandoned https://github.com/henrywhitaker3/Speedtest-Tracker/issues/1013.
66

7+
### Docs
8+
The docs can be found here https://docs.speedtest-tracker.dev to help you get started.
9+
710
### Roadmap
811
To suggest features please use the roadmap. You can also follow development progress there as well: https://speedtest-tracker-roadmap.alexjustesen.dev/
9-
10-
11-
### Deployment
12-
13-
#### Docker w/ sqlite
14-
```bash
15-
docker run -itd --name speedtest-tracker \
16-
-p 8080:80 \
17-
-e "PHP_POOL_NAME=speedtest-tracker_php" \
18-
-e "DB_CONNECTION=sqlite" \
19-
-e "DB_DATABASE=/app/database.sqlite" \
20-
-v speedtest-tracker_app:/app \
21-
speedtest-tracker
22-
```
23-
24-
#### Docker w/ MariaDB or MySQL
25-
```bash
26-
docker run -itd --name speedtest-tracker \
27-
-p 8080:80 \
28-
-e "PHP_POOL_NAME=speedtest-tracker_php" \
29-
-e "DB_CONNECTION=mysql" \
30-
-e "DB_HOST=mysql" \
31-
-e "DB_PORT=3306" \
32-
-e "DB_DATABASE=speedtest_tracker" \
33-
-e "DB_USERNAME=" \
34-
-e "DB_PASSWORD=" \
35-
speedtest-tracker
36-
```
37-
38-
#### Docker Compose
39-
```bash
40-
# tbd...
41-
```
42-
43-
44-
### Build Docker Image
45-
Want to build the image locally? Cool, just clone the repo and go right ahead...
46-
47-
```bash
48-
docker build . -t speedtest-tracker
49-
```
50-
51-
#### Runing the docker image
52-
```bash
53-
docker run -it -p 8080:80 \
54-
speedtest-tracker
55-
```
56-
57-
### Development
58-
59-
Since this project uses Laravel as our framework of choice we can take advantage of [Laravel Sail](https://laravel.com/docs/9.x/sail) for a development environment.
60-
61-
#### Clone the repo
62-
63-
```bash
64-
gh repo clone alexjustesen/speedtest-tracker \
65-
&& cd speedtest-tracker \
66-
&& cp .env.example .env
67-
```
68-
69-
#### Install composer dependencies
70-
```bash
71-
docker run --rm \
72-
-u "$(id -u):$(id -g)" \
73-
-v $(pwd):/var/www/html \
74-
-w /var/www/html \
75-
laravelsail/php81-composer:latest \
76-
composer install --ignore-platform-reqs
77-
```
78-
79-
#### Start sail
80-
```bash
81-
./vendor/bin/sail up -d
82-
83-
# or, if you have the sail bash alias
84-
sail up -d
85-
```

app/Console/Commands/AppStartupCommand.php

Lines changed: 0 additions & 107 deletions
This file was deleted.
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
<?php
2+
3+
namespace App\Console\Commands;
4+
5+
use Illuminate\Console\Command;
6+
use Illuminate\Support\Facades\Artisan;
7+
8+
class InstallCommand extends Command
9+
{
10+
/**
11+
* The name and signature of the console command.
12+
*
13+
* @var string
14+
*/
15+
protected $signature = 'app:install {--force}';
16+
17+
/**
18+
* The console command description.
19+
*
20+
* @var string
21+
*/
22+
protected $description = 'A fresh install of Speedtest Tracker.';
23+
24+
/**
25+
* Execute the console command.
26+
*
27+
* @return int
28+
*/
29+
public function handle()
30+
{
31+
if (! $this->option('force')) {
32+
$this->newLine(2);
33+
34+
$this->info("Running the install will reset all of the application's data.");
35+
$this->warn('!!! ALL OF THE DATA WILL BE DELETED !!!');
36+
37+
if (! $this->confirm('Do you wish to continue?')) {
38+
$this->info('Install cancelled.');
39+
40+
return 0;
41+
}
42+
}
43+
44+
$this->info('Starting to install the application...');
45+
46+
$this->newLine();
47+
48+
$this->checkAppKey();
49+
50+
$this->line('⏳ Optimizing the cache');
51+
52+
Artisan::call('optimize:clear');
53+
54+
$this->line('✅ Optimized cache');
55+
56+
$this->newLine();
57+
58+
$this->line('⏳ Migrating the database');
59+
60+
try {
61+
Artisan::call('migrate:fresh', [
62+
'--force' => true,
63+
]);
64+
} catch (\Throwable $th) {
65+
$this->error('❌ There was an issue migrating the database, check the logs.');
66+
67+
return 0;
68+
}
69+
70+
$this->line('✅ Database migrated');
71+
72+
$this->newLine();
73+
74+
$this->line('🚀 Finished installing the application!');
75+
76+
return 0;
77+
}
78+
79+
public function checkAppKey()
80+
{
81+
if (empty(config('app.key'))) {
82+
$this->line('🔑 Creating an application key');
83+
84+
Artisan::call('key:generate');
85+
86+
$this->line('✅ Application key created');
87+
}
88+
}
89+
}

app/Console/Commands/TestInfluxDB.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
use App\Models\Result;
66
use Illuminate\Console\Command;
77
use Illuminate\Support\Facades\File;
8-
use Illuminate\Support\Facades\Log;
9-
use InfluxDB2\Client;
108
use Symfony\Component\Yaml\Yaml;
119

1210
class TestInfluxDB extends Command

app/Jobs/ExecSpeedtest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
namespace App\Jobs;
44

55
use App\Models\Result;
6-
use App\Models\Speedtest;
76
use Illuminate\Bus\Queueable;
87
use Illuminate\Contracts\Queue\ShouldBeUnique;
98
use Illuminate\Contracts\Queue\ShouldQueue;
@@ -14,7 +13,7 @@
1413
use Symfony\Component\Process\Exception\ProcessFailedException;
1514
use Symfony\Component\Process\Process;
1615

17-
class ExecSpeedtest implements ShouldQueue
16+
class ExecSpeedtest implements ShouldQueue, ShouldBeUnique
1817
{
1918
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
2019

@@ -26,7 +25,8 @@ class ExecSpeedtest implements ShouldQueue
2625
public function __construct(
2726
public array|null $speedtest = null,
2827
public bool $scheduled = false
29-
) {}
28+
) {
29+
}
3030

3131
/**
3232
* Execute the job.
@@ -66,7 +66,7 @@ public function handle()
6666
'upload' => $results['upload']['bandwidth'],
6767
'server_id' => $results['server']['id'],
6868
'server_name' => $results['server']['name'],
69-
'server_host' => $results['server']['host'] . ':' . $results['server']['port'],
69+
'server_host' => $results['server']['host'].':'.$results['server']['port'],
7070
'url' => $results['result']['url'],
7171
'scheduled' => $this->scheduled,
7272
'data' => $output,

app/Jobs/SearchForSpeedtests.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
use Cron\CronExpression;
66
use Illuminate\Bus\Queueable;
7-
use Illuminate\Contracts\Queue\ShouldBeUnique;
87
use Illuminate\Contracts\Queue\ShouldQueue;
98
use Illuminate\Foundation\Bus\Dispatchable;
109
use Illuminate\Queue\InteractsWithQueue;

app/Observers/ResultObserver.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public function created(Result $result)
4343
'token' => $influxdb['token'],
4444
'bucket' => $influxdb['bucket'],
4545
'org' => $influxdb['org'],
46-
'precision' => \InfluxDB2\Model\WritePrecision::S
46+
'precision' => \InfluxDB2\Model\WritePrecision::S,
4747
]);
4848

4949
$writeApi = $client->createWriteApi();

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"require-dev": {
1818
"barryvdh/laravel-ide-helper": "^2.12",
1919
"fakerphp/faker": "^1.9.1",
20-
"laravel/pint": "^1.0",
20+
"laravel/pint": "^1.2",
2121
"laravel/sail": "^1.0.1",
2222
"mockery/mockery": "^1.4.4",
2323
"nunomaduro/collision": "^6.1",

0 commit comments

Comments
 (0)