Skip to content

Commit

Permalink
[Chore] Remove support for sqlite (#669)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexjustesen authored Aug 2, 2023
1 parent a0ba461 commit 3024123
Show file tree
Hide file tree
Showing 7 changed files with 61 additions and 51 deletions.
17 changes: 8 additions & 9 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
APP_NAME="Speedtest Tracker"
APP_ENV=production
APP_ENV=local
APP_KEY=
APP_DEBUG=false
APP_URL=http://localhost
FORCE_HTTPS=false

LOG_CHANNEL=stderr
LOG_CHANNEL=stack
LOG_DEPRECATIONS_CHANNEL=null
LOG_LEVEL=debug

DB_CONNECTION=sqlite
# DB_HOST=127.0.0.1
# DB_PORT=3306
# DB_DATABASE=speedtest_tracker
# DB_USERNAME=root
# DB_PASSWORD=
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=speedtest_tracker
DB_USERNAME=
DB_PASSWORD=

BROADCAST_DRIVER=log
CACHE_DRIVER=database
Expand Down
42 changes: 42 additions & 0 deletions .env.production
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
APP_NAME="Speedtest Tracker"
APP_ENV=production
APP_KEY=
APP_DEBUG=false
APP_URL=http://localhost

FORCE_HTTPS=false

LOG_CHANNEL=stderr
LOG_DEPRECATIONS_CHANNEL=null
LOG_LEVEL=debug

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=speedtest_tracker
DB_USERNAME=
DB_PASSWORD=

BROADCAST_DRIVER=log
CACHE_DRIVER=database
FILESYSTEM_DISK=local
QUEUE_CONNECTION=database
SESSION_DRIVER=database
SESSION_LIFETIME=120

MAIL_MAILER=smtp
MAIL_HOST=mailhog
MAIL_PORT=1025
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
MAIL_FROM_ADDRESS="hello@example.com"
MAIL_FROM_NAME="${APP_NAME}"

AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
AWS_DEFAULT_REGION=us-east-1
AWS_BUCKET=
AWS_USE_PATH_STYLE_ENDPOINT=false

TELEGRAM_BOT_TOKEN=
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ jobs:
- name: Check syntax
run: phplint .
- name: Check code style
run: pint --test
run: pint --test -v
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ As far as I can tell https://github.com/henrywhitaker3/Speedtest-Tracker was aba

## Getting Started

Speedtest Tracker is containerized so you can run it anywhere you run your Docker containers. The [install](https://docs.speedtest-tracker.dev/getting-started/installation) documentation will get you up and running with using Docker or Docker Composer along with choosing a database (SQLite, MySQL/MariaDB or Postgresql).
Speedtest Tracker is containerized so you can run it anywhere you run your Docker containers. The [install](https://docs.speedtest-tracker.dev/getting-started/installation) documentation will get you up and running with using Docker or Docker Composer along with choosing a database (MySQL/MariaDB or Postgresql).

### FAQs and Features

Expand Down
14 changes: 7 additions & 7 deletions app/Filament/Resources/ResultResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public static function table(Table $table): Table
TextColumn::make('id')
->label('ID'),
TextColumn::make('server')
->getStateUsing(fn (Result $record): string|null => ! blank($record->server_id) ? $record->server_id.' ('.$record->server_name.')' : null)
->getStateUsing(fn (Result $record): ?string => ! blank($record->server_id) ? $record->server_id.' ('.$record->server_name.')' : null)
->toggleable(),
IconColumn::make('successful')
->boolean()
Expand All @@ -112,23 +112,23 @@ public static function table(Table $table): Table
->toggleable(),
TextColumn::make('download')
->label('Download (Mbps)')
->getStateUsing(fn (Result $record): string|null => ! blank($record->download) ? toBits(convertSize($record->download), 2) : null),
->getStateUsing(fn (Result $record): ?string => ! blank($record->download) ? toBits(convertSize($record->download), 2) : null),
TextColumn::make('upload')
->label('Upload (Mbps)')
->getStateUsing(fn (Result $record): string|null => ! blank($record->upload) ? toBits(convertSize($record->upload), 2) : null),
->getStateUsing(fn (Result $record): ?string => ! blank($record->upload) ? toBits(convertSize($record->upload), 2) : null),
TextColumn::make('ping')
->label('Ping (Ms)')
->toggleable(),
TextColumn::make('download_jitter')
->getStateUsing(fn (Result $record): string|null => json_decode($record->data, true)['download']['latency']['jitter'] ?? null)
->getStateUsing(fn (Result $record): ?string => json_decode($record->data, true)['download']['latency']['jitter'] ?? null)
->toggleable()
->toggledHiddenByDefault(),
TextColumn::make('upload_jitter')
->getStateUsing(fn (Result $record): string|null => json_decode($record->data, true)['upload']['latency']['jitter'] ?? null)
->getStateUsing(fn (Result $record): ?string => json_decode($record->data, true)['upload']['latency']['jitter'] ?? null)
->toggleable()
->toggledHiddenByDefault(),
TextColumn::make('ping_jitter')
->getStateUsing(fn (Result $record): string|null => json_decode($record->data, true)['ping']['jitter'] ?? null)
->getStateUsing(fn (Result $record): ?string => json_decode($record->data, true)['ping']['jitter'] ?? null)
->toggleable()
->toggledHiddenByDefault(),
TextColumn::make('created_at')
Expand Down Expand Up @@ -162,7 +162,7 @@ public static function table(Table $table): Table
Action::make('view result')
->label('View on Speedtest.net')
->icon('heroicon-o-link')
->url(fn (Result $record): string|null => $record?->url)
->url(fn (Result $record): ?string => $record?->url)
->hidden(fn (Result $record): bool => ! $record->is_successful)
->openUrlInNewTab(),
Tables\Actions\ViewAction::make(),
Expand Down
2 changes: 1 addition & 1 deletion app/Jobs/ExecSpeedtest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class ExecSpeedtest implements ShouldQueue, ShouldBeUnique
* @return void
*/
public function __construct(
public array|null $speedtest = null,
public ?array $speedtest = null,
public bool $scheduled = false
) {
}
Expand Down
33 changes: 1 addition & 32 deletions docker/deploy/etc/s6-overlay/scripts/laravel-automations
Original file line number Diff line number Diff line change
Expand Up @@ -15,41 +15,10 @@ chown -R webuser:webgroup $WEBUSER_HOME
echo "✅ Permissions fixed."
echo ""

if [ ${DB_CONNECTION:="sqlite"} = "sqlite" ]; then
# Check for database
if [ ! -f /config/database.sqlite ]; then
echo "🙄 SQLite database not found, creating..."
s6-setuidgid webuser touch /config/database.sqlite
echo "✅ SQLite database created."
else
echo "✅ Database already exists."
fi
echo ""

# create symlinks
echo "🔗 Creating database symlink..."
symlinks=( \
/var/www/html/database/database.sqlite \
)

for i in "${symlinks[@]}"
do
if [[ -e "$i" && ! -L "$i" ]]; then
rm -rf "$i"
fi
if [[ ! -L "$i" ]]; then
ln -s /config/"$(basename "$i")" "$i"
fi
done

echo "✅ Database symlink created."
echo ""
fi

# Check for env file
if [ ! -f /config/.env ]; then
echo "🙄 Environment file not found, creating..."
s6-setuidgid webuser cp $WEBUSER_HOME/.env.example /config/.env
s6-setuidgid webuser cp $WEBUSER_HOME/.env.production /config/.env
echo "✅ Environment file created."
else
echo "✅ Environment file exists."
Expand Down

0 comments on commit 3024123

Please sign in to comment.