From a3ec2c3cd52694e4e47e80790e9af778f6275ca8 Mon Sep 17 00:00:00 2001 From: JoaoMG Date: Wed, 9 Nov 2022 23:45:28 +0000 Subject: [PATCH 1/4] Update FilamentServiceProvider.php (#135) --- app/Providers/FilamentServiceProvider.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Providers/FilamentServiceProvider.php b/app/Providers/FilamentServiceProvider.php index fb2b9d8c6..e2fd5ae1f 100644 --- a/app/Providers/FilamentServiceProvider.php +++ b/app/Providers/FilamentServiceProvider.php @@ -38,7 +38,7 @@ public function boot() ]); Filament::registerNavigationItems([ - NavigationItem::make('Documenation') + NavigationItem::make('Documentation') ->url('https://docs.speedtest-tracker.dev/', shouldOpenInNewTab: true) ->icon('heroicon-o-external-link') ->group('Links') From 37405dd42b8743ad7591eefa090b507a919e56f9 Mon Sep 17 00:00:00 2001 From: Alex Justesen Date: Thu, 10 Nov 2022 07:24:12 -0500 Subject: [PATCH 2/4] CI workflow (#137) --- .github/workflows/ci.yml | 53 ++++++ _ide_helper.php | 65 ++++++- app/Observers/ResultObserver.php | 2 +- app/Policies/FailedJobPolicy.php | 6 +- composer.lock | 310 +++++++++++++------------------ tests/Feature/ExampleTest.php | 2 +- 6 files changed, 244 insertions(+), 194 deletions(-) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 000000000..50550c8ff --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,53 @@ +name: CI + +on: + workflow_dispatch: + pull_request: + branches: [ main ] + +jobs: + test-app: + name: Test Speedtest Tracker (PHP ${{ matrix.php-versions }} on ${{ matrix.operating-system }}) + runs-on: ${{ matrix.operating-system }} + + strategy: + fail-fast: false + matrix: + operating-system: ['ubuntu-22.04'] + php-versions: ['8.1'] + + steps: + - uses: actions/checkout@v2 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php-versions }} + extensions: mbstring, dom, fileinfo + coverage: xdebug + + - name: Get composer cache directory + id: composer-cache + run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT + + - name: Cache composer dependencies + uses: actions/cache@v3 + with: + path: ${{ steps.composer-cache.outputs.dir }} + key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} + restore-keys: ${{ runner.os }}-composer- + + - name: Install Composer dependencies + run: composer install --no-progress --prefer-dist --optimize-autoloader + + - name: Install the application + run: | + touch database/database.sqlite + php -r "file_exists('.env') || copy('.env.example', '.env');" + php artisan app:install --force + + - name: Evaluate code quality + run: vendor/bin/pint --test + + - name: Test with phpunit including coverage + run: vendor/bin/phpunit --coverage-text diff --git a/_ide_helper.php b/_ide_helper.php index b40c70d49..ac7bcd5b4 100644 --- a/_ide_helper.php +++ b/_ide_helper.php @@ -4,7 +4,7 @@ /** * A helper file for Laravel, to provide autocomplete information to your IDE - * Generated for Laravel 9.38.0. + * Generated for Laravel 9.39.0. * * This file should not be included in your code, only analyzed by your IDE! * @@ -12990,13 +12990,13 @@ public static function apiResource($name, $controller, $options = []) * * @param array $attributes * @param \Closure|array|string $routes - * @return void + * @return \Illuminate\Routing\Router * @static */ public static function group($attributes, $routes) { /** @var \Illuminate\Routing\Router $instance */ - $instance->group($attributes, $routes); + return $instance->group($attributes, $routes); } /** * Merge the given array with the last group stack. @@ -16830,6 +16830,65 @@ public static function callCreator($view) { /** @var \Illuminate\View\Factory $instance */ $instance->callCreator($view); + } + /** + * Start injecting content into a fragment. + * + * @param string $fragment + * @return void + * @static + */ + public static function startFragment($fragment) + { + /** @var \Illuminate\View\Factory $instance */ + $instance->startFragment($fragment); + } + /** + * Stop injecting content into a fragment. + * + * @return string + * @throws \InvalidArgumentException + * @static + */ + public static function stopFragment() + { + /** @var \Illuminate\View\Factory $instance */ + return $instance->stopFragment(); + } + /** + * Get the contents of a fragment. + * + * @param string $name + * @param string|null $default + * @return mixed + * @static + */ + public static function getFragment($name, $default = null) + { + /** @var \Illuminate\View\Factory $instance */ + return $instance->getFragment($name, $default); + } + /** + * Get the entire array of rendered fragments. + * + * @return array + * @static + */ + public static function getFragments() + { + /** @var \Illuminate\View\Factory $instance */ + return $instance->getFragments(); + } + /** + * Flush all of the fragments. + * + * @return void + * @static + */ + public static function flushFragments() + { + /** @var \Illuminate\View\Factory $instance */ + $instance->flushFragments(); } /** * Start injecting content into a section. diff --git a/app/Observers/ResultObserver.php b/app/Observers/ResultObserver.php index 1dc0e253f..bc0924db0 100644 --- a/app/Observers/ResultObserver.php +++ b/app/Observers/ResultObserver.php @@ -63,7 +63,7 @@ public function created(Result $result) // Send data to time series databases if ($this->influxDbSettings->v2_enabled) { - SendDataToInfluxDbV2::dispatch($result,$this->influxDbSettings); + SendDataToInfluxDbV2::dispatch($result, $this->influxDbSettings); } } diff --git a/app/Policies/FailedJobPolicy.php b/app/Policies/FailedJobPolicy.php index d78548bd8..0fd016b7d 100644 --- a/app/Policies/FailedJobPolicy.php +++ b/app/Policies/FailedJobPolicy.php @@ -10,7 +10,7 @@ class FailedJobPolicy use HandlesAuthorization; public function viewAny(User $user): bool - { - return config('app.debug'); - } + { + return config('app.debug'); + } } diff --git a/composer.lock b/composer.lock index b2101f99b..605d39cae 100644 --- a/composer.lock +++ b/composer.lock @@ -1149,16 +1149,16 @@ }, { "name": "filament/filament", - "version": "v2.16.39", + "version": "v2.16.45", "source": { "type": "git", "url": "https://github.com/filamentphp/admin.git", - "reference": "49d9460887fcf295faec180a759a57c8b0d48447" + "reference": "f79b1c32ef1b0c6901367cb6f854ad8ccdb1fb1a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/filamentphp/admin/zipball/49d9460887fcf295faec180a759a57c8b0d48447", - "reference": "49d9460887fcf295faec180a759a57c8b0d48447", + "url": "https://api.github.com/repos/filamentphp/admin/zipball/f79b1c32ef1b0c6901367cb6f854ad8ccdb1fb1a", + "reference": "f79b1c32ef1b0c6901367cb6f854ad8ccdb1fb1a", "shasum": "" }, "require": { @@ -1208,20 +1208,20 @@ "issues": "https://github.com/filamentphp/filament/issues", "source": "https://github.com/filamentphp/filament" }, - "time": "2022-11-03T14:39:59+00:00" + "time": "2022-11-09T22:06:02+00:00" }, { "name": "filament/forms", - "version": "v2.16.39", + "version": "v2.16.45", "source": { "type": "git", "url": "https://github.com/filamentphp/forms.git", - "reference": "64fc90b4bae5b1d14bbdec8fa48557504c39a20e" + "reference": "3ec7df2e33a9eba76a4a3845d9fb211c0762b8f2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/filamentphp/forms/zipball/64fc90b4bae5b1d14bbdec8fa48557504c39a20e", - "reference": "64fc90b4bae5b1d14bbdec8fa48557504c39a20e", + "url": "https://api.github.com/repos/filamentphp/forms/zipball/3ec7df2e33a9eba76a4a3845d9fb211c0762b8f2", + "reference": "3ec7df2e33a9eba76a4a3845d9fb211c0762b8f2", "shasum": "" }, "require": { @@ -1266,20 +1266,20 @@ "issues": "https://github.com/filamentphp/filament/issues", "source": "https://github.com/filamentphp/filament" }, - "time": "2022-11-03T14:40:06+00:00" + "time": "2022-11-09T22:06:02+00:00" }, { "name": "filament/notifications", - "version": "v2.16.39", + "version": "v2.16.45", "source": { "type": "git", "url": "https://github.com/filamentphp/notifications.git", - "reference": "ff9137bb1fa5568f923ae5afd35ec90c20459aa5" + "reference": "45a17e50dbffe17852811c4181309e23deb24b97" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/filamentphp/notifications/zipball/ff9137bb1fa5568f923ae5afd35ec90c20459aa5", - "reference": "ff9137bb1fa5568f923ae5afd35ec90c20459aa5", + "url": "https://api.github.com/repos/filamentphp/notifications/zipball/45a17e50dbffe17852811c4181309e23deb24b97", + "reference": "45a17e50dbffe17852811c4181309e23deb24b97", "shasum": "" }, "require": { @@ -1316,11 +1316,11 @@ "issues": "https://github.com/filamentphp/filament/issues", "source": "https://github.com/filamentphp/filament" }, - "time": "2022-10-30T20:32:21+00:00" + "time": "2022-11-09T16:25:58+00:00" }, { "name": "filament/spatie-laravel-settings-plugin", - "version": "v2.16.39", + "version": "v2.16.45", "source": { "type": "git", "url": "https://github.com/filamentphp/spatie-laravel-settings-plugin.git", @@ -1367,16 +1367,16 @@ }, { "name": "filament/support", - "version": "v2.16.39", + "version": "v2.16.45", "source": { "type": "git", "url": "https://github.com/filamentphp/support.git", - "reference": "548ab60c617568ecea13ff8ea3cce21a5961afb1" + "reference": "da25e4d0b630855388400c5302e4fc9a58865a7a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/filamentphp/support/zipball/548ab60c617568ecea13ff8ea3cce21a5961afb1", - "reference": "548ab60c617568ecea13ff8ea3cce21a5961afb1", + "url": "https://api.github.com/repos/filamentphp/support/zipball/da25e4d0b630855388400c5302e4fc9a58865a7a", + "reference": "da25e4d0b630855388400c5302e4fc9a58865a7a", "shasum": "" }, "require": { @@ -1413,20 +1413,20 @@ "issues": "https://github.com/filamentphp/filament/issues", "source": "https://github.com/filamentphp/filament" }, - "time": "2022-11-03T14:40:22+00:00" + "time": "2022-11-09T21:59:01+00:00" }, { "name": "filament/tables", - "version": "v2.16.39", + "version": "v2.16.45", "source": { "type": "git", "url": "https://github.com/filamentphp/tables.git", - "reference": "8b7bbda5cf899687982154043be7edfc254ac07b" + "reference": "4f546c9b916c688cac4f1d905c84e10bf577f408" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/filamentphp/tables/zipball/8b7bbda5cf899687982154043be7edfc254ac07b", - "reference": "8b7bbda5cf899687982154043be7edfc254ac07b", + "url": "https://api.github.com/repos/filamentphp/tables/zipball/4f546c9b916c688cac4f1d905c84e10bf577f408", + "reference": "4f546c9b916c688cac4f1d905c84e10bf577f408", "shasum": "" }, "require": { @@ -1469,7 +1469,7 @@ "issues": "https://github.com/filamentphp/filament/issues", "source": "https://github.com/filamentphp/filament" }, - "time": "2022-11-03T14:40:26+00:00" + "time": "2022-11-09T22:06:36+00:00" }, { "name": "fruitcake/php-cors", @@ -2058,16 +2058,16 @@ }, { "name": "laravel/framework", - "version": "v9.38.0", + "version": "v9.39.0", "source": { "type": "git", "url": "https://github.com/laravel/framework.git", - "reference": "abf198e443e06696af3f356b44de67c0fa516107" + "reference": "67e674709e1e7db14f304a871481f310822d68c5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/framework/zipball/abf198e443e06696af3f356b44de67c0fa516107", - "reference": "abf198e443e06696af3f356b44de67c0fa516107", + "url": "https://api.github.com/repos/laravel/framework/zipball/67e674709e1e7db14f304a871481f310822d68c5", + "reference": "67e674709e1e7db14f304a871481f310822d68c5", "shasum": "" }, "require": { @@ -2240,7 +2240,7 @@ "issues": "https://github.com/laravel/framework/issues", "source": "https://github.com/laravel/framework" }, - "time": "2022-11-01T14:05:55+00:00" + "time": "2022-11-08T14:47:39+00:00" }, { "name": "laravel/sanctum", @@ -3085,16 +3085,16 @@ }, { "name": "nesbot/carbon", - "version": "2.62.1", + "version": "2.63.0", "source": { "type": "git", "url": "https://github.com/briannesbitt/Carbon.git", - "reference": "01bc4cdefe98ef58d1f9cb31bdbbddddf2a88f7a" + "reference": "ad35dd71a6a212b98e4b87e97389b6fa85f0e347" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/briannesbitt/Carbon/zipball/01bc4cdefe98ef58d1f9cb31bdbbddddf2a88f7a", - "reference": "01bc4cdefe98ef58d1f9cb31bdbbddddf2a88f7a", + "url": "https://api.github.com/repos/briannesbitt/Carbon/zipball/ad35dd71a6a212b98e4b87e97389b6fa85f0e347", + "reference": "ad35dd71a6a212b98e4b87e97389b6fa85f0e347", "shasum": "" }, "require": { @@ -3183,7 +3183,7 @@ "type": "tidelift" } ], - "time": "2022-09-02T07:48:13+00:00" + "time": "2022-10-30T18:34:28+00:00" }, { "name": "nette/schema", @@ -4072,16 +4072,16 @@ }, { "name": "psy/psysh", - "version": "v0.11.8", + "version": "v0.11.9", "source": { "type": "git", "url": "https://github.com/bobthecow/psysh.git", - "reference": "f455acf3645262ae389b10e9beba0c358aa6994e" + "reference": "1acec99d6684a54ff92f8b548a4e41b566963778" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/bobthecow/psysh/zipball/f455acf3645262ae389b10e9beba0c358aa6994e", - "reference": "f455acf3645262ae389b10e9beba0c358aa6994e", + "url": "https://api.github.com/repos/bobthecow/psysh/zipball/1acec99d6684a54ff92f8b548a4e41b566963778", + "reference": "1acec99d6684a54ff92f8b548a4e41b566963778", "shasum": "" }, "require": { @@ -4142,9 +4142,9 @@ ], "support": { "issues": "https://github.com/bobthecow/psysh/issues", - "source": "https://github.com/bobthecow/psysh/tree/v0.11.8" + "source": "https://github.com/bobthecow/psysh/tree/v0.11.9" }, - "time": "2022-07-28T14:25:11+00:00" + "time": "2022-11-06T15:29:46+00:00" }, { "name": "ralouphie/getallheaders", @@ -4271,21 +4271,20 @@ }, { "name": "ramsey/uuid", - "version": "4.5.1", + "version": "4.6.0", "source": { "type": "git", "url": "https://github.com/ramsey/uuid.git", - "reference": "a161a26d917604dc6d3aa25100fddf2556e9f35d" + "reference": "ad63bc700e7d021039e30ce464eba384c4a1d40f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/ramsey/uuid/zipball/a161a26d917604dc6d3aa25100fddf2556e9f35d", - "reference": "a161a26d917604dc6d3aa25100fddf2556e9f35d", + "url": "https://api.github.com/repos/ramsey/uuid/zipball/ad63bc700e7d021039e30ce464eba384c4a1d40f", + "reference": "ad63bc700e7d021039e30ce464eba384c4a1d40f", "shasum": "" }, "require": { "brick/math": "^0.8.8 || ^0.9 || ^0.10", - "ext-ctype": "*", "ext-json": "*", "php": "^8.0", "ramsey/collection": "^1.0" @@ -4317,7 +4316,6 @@ }, "suggest": { "ext-bcmath": "Enables faster math with arbitrary-precision integers using BCMath.", - "ext-ctype": "Enables faster processing of character classification using ctype functions.", "ext-gmp": "Enables faster math with arbitrary-precision integers using GMP.", "ext-uuid": "Enables the use of PeclUuidTimeGenerator and PeclUuidRandomGenerator.", "paragonie/random-lib": "Provides RandomLib for use with the RandomLibAdapter", @@ -4349,7 +4347,7 @@ ], "support": { "issues": "https://github.com/ramsey/uuid/issues", - "source": "https://github.com/ramsey/uuid/tree/4.5.1" + "source": "https://github.com/ramsey/uuid/tree/4.6.0" }, "funding": [ { @@ -4361,7 +4359,7 @@ "type": "tidelift" } ], - "time": "2022-09-16T03:22:46+00:00" + "time": "2022-11-05T23:03:38+00:00" }, { "name": "ryangjchandler/blade-capture-directive", @@ -4520,70 +4518,6 @@ ], "time": "2022-08-09T08:17:56+00:00" }, - { - "name": "spatie/data-transfer-object", - "version": "3.9.1", - "source": { - "type": "git", - "url": "https://github.com/spatie/data-transfer-object.git", - "reference": "1df0906c4e9e3aebd6c0506fd82c8b7d5548c1c8" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/spatie/data-transfer-object/zipball/1df0906c4e9e3aebd6c0506fd82c8b7d5548c1c8", - "reference": "1df0906c4e9e3aebd6c0506fd82c8b7d5548c1c8", - "shasum": "" - }, - "require": { - "php": "^8.0" - }, - "require-dev": { - "illuminate/collections": "^8.36", - "jetbrains/phpstorm-attributes": "^1.0", - "larapack/dd": "^1.1", - "phpunit/phpunit": "^9.5.5" - }, - "type": "library", - "autoload": { - "psr-4": { - "Spatie\\DataTransferObject\\": "src" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Brent Roose", - "email": "brent@spatie.be", - "homepage": "https://spatie.be", - "role": "Developer" - } - ], - "description": "Data transfer objects with batteries included", - "homepage": "https://github.com/spatie/data-transfer-object", - "keywords": [ - "data-transfer-object", - "spatie" - ], - "support": { - "issues": "https://github.com/spatie/data-transfer-object/issues", - "source": "https://github.com/spatie/data-transfer-object/tree/3.9.1" - }, - "funding": [ - { - "url": "https://spatie.be/open-source/support-us", - "type": "custom" - }, - { - "url": "https://github.com/spatie", - "type": "github" - } - ], - "abandoned": "spatie/laravel-data", - "time": "2022-09-16T13:34:38+00:00" - }, { "name": "spatie/invade", "version": "1.1.1", @@ -4711,16 +4645,16 @@ }, { "name": "spatie/laravel-settings", - "version": "2.4.5", + "version": "2.5.0", "source": { "type": "git", "url": "https://github.com/spatie/laravel-settings.git", - "reference": "f16a8d29c126deadddb84fff495212d2393cc850" + "reference": "bdf84fa4f1fd0196c389ebc996b7d1bc8be2f17e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/spatie/laravel-settings/zipball/f16a8d29c126deadddb84fff495212d2393cc850", - "reference": "f16a8d29c126deadddb84fff495212d2393cc850", + "url": "https://api.github.com/repos/spatie/laravel-settings/zipball/bdf84fa4f1fd0196c389ebc996b7d1bc8be2f17e", + "reference": "bdf84fa4f1fd0196c389ebc996b7d1bc8be2f17e", "shasum": "" }, "require": { @@ -4729,13 +4663,12 @@ "illuminate/database": "^8.73|^9.0", "php": "^7.4|^8.0", "phpdocumentor/type-resolver": "^1.5", - "spatie/data-transfer-object": "^2.8|^3.7", "spatie/temporary-directory": "^1.3|^2.0" }, "require-dev": { "ext-redis": "*", "mockery/mockery": "^1.4", - "nunomaduro/larastan": "^1.0", + "nunomaduro/larastan": "^2.0", "orchestra/testbench": "^6.23|^7.0", "pestphp/pest": "^1.21", "pestphp/pest-plugin-laravel": "^1.2", @@ -4743,8 +4676,13 @@ "phpstan/phpstan-deprecation-rules": "^1.0", "phpstan/phpstan-phpunit": "^1.0", "phpunit/phpunit": "^9.5", + "spatie/laravel-data": "^1.0.0|^2.0.0", "spatie/pest-plugin-snapshots": "^1.1", - "spatie/phpunit-snapshot-assertions": "^4.2" + "spatie/phpunit-snapshot-assertions": "^4.2", + "spatie/ray": "^1.36" + }, + "suggest": { + "spatie/data-transfer-object": "Allows for DTO casting to settings. (deprecated)" }, "type": "library", "extra": { @@ -4779,7 +4717,7 @@ ], "support": { "issues": "https://github.com/spatie/laravel-settings/issues", - "source": "https://github.com/spatie/laravel-settings/tree/2.4.5" + "source": "https://github.com/spatie/laravel-settings/tree/2.5.0" }, "funding": [ { @@ -4791,7 +4729,7 @@ "type": "github" } ], - "time": "2022-09-28T14:10:27+00:00" + "time": "2022-11-10T09:29:03+00:00" }, { "name": "spatie/temporary-directory", @@ -5985,16 +5923,16 @@ }, { "name": "symfony/polyfill-ctype", - "version": "v1.26.0", + "version": "v1.27.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-ctype.git", - "reference": "6fd1b9a79f6e3cf65f9e679b23af304cd9e010d4" + "reference": "5bbc823adecdae860bb64756d639ecfec17b050a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/6fd1b9a79f6e3cf65f9e679b23af304cd9e010d4", - "reference": "6fd1b9a79f6e3cf65f9e679b23af304cd9e010d4", + "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/5bbc823adecdae860bb64756d639ecfec17b050a", + "reference": "5bbc823adecdae860bb64756d639ecfec17b050a", "shasum": "" }, "require": { @@ -6009,7 +5947,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "1.26-dev" + "dev-main": "1.27-dev" }, "thanks": { "name": "symfony/polyfill", @@ -6047,7 +5985,7 @@ "portable" ], "support": { - "source": "https://github.com/symfony/polyfill-ctype/tree/v1.26.0" + "source": "https://github.com/symfony/polyfill-ctype/tree/v1.27.0" }, "funding": [ { @@ -6063,20 +6001,20 @@ "type": "tidelift" } ], - "time": "2022-05-24T11:49:31+00:00" + "time": "2022-11-03T14:55:06+00:00" }, { "name": "symfony/polyfill-intl-grapheme", - "version": "v1.26.0", + "version": "v1.27.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-intl-grapheme.git", - "reference": "433d05519ce6990bf3530fba6957499d327395c2" + "reference": "511a08c03c1960e08a883f4cffcacd219b758354" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-intl-grapheme/zipball/433d05519ce6990bf3530fba6957499d327395c2", - "reference": "433d05519ce6990bf3530fba6957499d327395c2", + "url": "https://api.github.com/repos/symfony/polyfill-intl-grapheme/zipball/511a08c03c1960e08a883f4cffcacd219b758354", + "reference": "511a08c03c1960e08a883f4cffcacd219b758354", "shasum": "" }, "require": { @@ -6088,7 +6026,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "1.26-dev" + "dev-main": "1.27-dev" }, "thanks": { "name": "symfony/polyfill", @@ -6128,7 +6066,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-intl-grapheme/tree/v1.26.0" + "source": "https://github.com/symfony/polyfill-intl-grapheme/tree/v1.27.0" }, "funding": [ { @@ -6144,20 +6082,20 @@ "type": "tidelift" } ], - "time": "2022-05-24T11:49:31+00:00" + "time": "2022-11-03T14:55:06+00:00" }, { "name": "symfony/polyfill-intl-idn", - "version": "v1.26.0", + "version": "v1.27.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-intl-idn.git", - "reference": "59a8d271f00dd0e4c2e518104cc7963f655a1aa8" + "reference": "639084e360537a19f9ee352433b84ce831f3d2da" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-intl-idn/zipball/59a8d271f00dd0e4c2e518104cc7963f655a1aa8", - "reference": "59a8d271f00dd0e4c2e518104cc7963f655a1aa8", + "url": "https://api.github.com/repos/symfony/polyfill-intl-idn/zipball/639084e360537a19f9ee352433b84ce831f3d2da", + "reference": "639084e360537a19f9ee352433b84ce831f3d2da", "shasum": "" }, "require": { @@ -6171,7 +6109,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "1.26-dev" + "dev-main": "1.27-dev" }, "thanks": { "name": "symfony/polyfill", @@ -6215,7 +6153,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-intl-idn/tree/v1.26.0" + "source": "https://github.com/symfony/polyfill-intl-idn/tree/v1.27.0" }, "funding": [ { @@ -6231,20 +6169,20 @@ "type": "tidelift" } ], - "time": "2022-05-24T11:49:31+00:00" + "time": "2022-11-03T14:55:06+00:00" }, { "name": "symfony/polyfill-intl-normalizer", - "version": "v1.26.0", + "version": "v1.27.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-intl-normalizer.git", - "reference": "219aa369ceff116e673852dce47c3a41794c14bd" + "reference": "19bd1e4fcd5b91116f14d8533c57831ed00571b6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-intl-normalizer/zipball/219aa369ceff116e673852dce47c3a41794c14bd", - "reference": "219aa369ceff116e673852dce47c3a41794c14bd", + "url": "https://api.github.com/repos/symfony/polyfill-intl-normalizer/zipball/19bd1e4fcd5b91116f14d8533c57831ed00571b6", + "reference": "19bd1e4fcd5b91116f14d8533c57831ed00571b6", "shasum": "" }, "require": { @@ -6256,7 +6194,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "1.26-dev" + "dev-main": "1.27-dev" }, "thanks": { "name": "symfony/polyfill", @@ -6299,7 +6237,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-intl-normalizer/tree/v1.26.0" + "source": "https://github.com/symfony/polyfill-intl-normalizer/tree/v1.27.0" }, "funding": [ { @@ -6315,20 +6253,20 @@ "type": "tidelift" } ], - "time": "2022-05-24T11:49:31+00:00" + "time": "2022-11-03T14:55:06+00:00" }, { "name": "symfony/polyfill-mbstring", - "version": "v1.26.0", + "version": "v1.27.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-mbstring.git", - "reference": "9344f9cb97f3b19424af1a21a3b0e75b0a7d8d7e" + "reference": "8ad114f6b39e2c98a8b0e3bd907732c207c2b534" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/9344f9cb97f3b19424af1a21a3b0e75b0a7d8d7e", - "reference": "9344f9cb97f3b19424af1a21a3b0e75b0a7d8d7e", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/8ad114f6b39e2c98a8b0e3bd907732c207c2b534", + "reference": "8ad114f6b39e2c98a8b0e3bd907732c207c2b534", "shasum": "" }, "require": { @@ -6343,7 +6281,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "1.26-dev" + "dev-main": "1.27-dev" }, "thanks": { "name": "symfony/polyfill", @@ -6382,7 +6320,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.26.0" + "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.27.0" }, "funding": [ { @@ -6398,20 +6336,20 @@ "type": "tidelift" } ], - "time": "2022-05-24T11:49:31+00:00" + "time": "2022-11-03T14:55:06+00:00" }, { "name": "symfony/polyfill-php72", - "version": "v1.26.0", + "version": "v1.27.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-php72.git", - "reference": "bf44a9fd41feaac72b074de600314a93e2ae78e2" + "reference": "869329b1e9894268a8a61dabb69153029b7a8c97" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php72/zipball/bf44a9fd41feaac72b074de600314a93e2ae78e2", - "reference": "bf44a9fd41feaac72b074de600314a93e2ae78e2", + "url": "https://api.github.com/repos/symfony/polyfill-php72/zipball/869329b1e9894268a8a61dabb69153029b7a8c97", + "reference": "869329b1e9894268a8a61dabb69153029b7a8c97", "shasum": "" }, "require": { @@ -6420,7 +6358,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "1.26-dev" + "dev-main": "1.27-dev" }, "thanks": { "name": "symfony/polyfill", @@ -6458,7 +6396,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-php72/tree/v1.26.0" + "source": "https://github.com/symfony/polyfill-php72/tree/v1.27.0" }, "funding": [ { @@ -6474,20 +6412,20 @@ "type": "tidelift" } ], - "time": "2022-05-24T11:49:31+00:00" + "time": "2022-11-03T14:55:06+00:00" }, { "name": "symfony/polyfill-php80", - "version": "v1.26.0", + "version": "v1.27.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-php80.git", - "reference": "cfa0ae98841b9e461207c13ab093d76b0fa7bace" + "reference": "7a6ff3f1959bb01aefccb463a0f2cd3d3d2fd936" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/cfa0ae98841b9e461207c13ab093d76b0fa7bace", - "reference": "cfa0ae98841b9e461207c13ab093d76b0fa7bace", + "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/7a6ff3f1959bb01aefccb463a0f2cd3d3d2fd936", + "reference": "7a6ff3f1959bb01aefccb463a0f2cd3d3d2fd936", "shasum": "" }, "require": { @@ -6496,7 +6434,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "1.26-dev" + "dev-main": "1.27-dev" }, "thanks": { "name": "symfony/polyfill", @@ -6541,7 +6479,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-php80/tree/v1.26.0" + "source": "https://github.com/symfony/polyfill-php80/tree/v1.27.0" }, "funding": [ { @@ -6557,20 +6495,20 @@ "type": "tidelift" } ], - "time": "2022-05-10T07:21:04+00:00" + "time": "2022-11-03T14:55:06+00:00" }, { "name": "symfony/polyfill-php81", - "version": "v1.26.0", + "version": "v1.27.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-php81.git", - "reference": "13f6d1271c663dc5ae9fb843a8f16521db7687a1" + "reference": "707403074c8ea6e2edaf8794b0157a0bfa52157a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php81/zipball/13f6d1271c663dc5ae9fb843a8f16521db7687a1", - "reference": "13f6d1271c663dc5ae9fb843a8f16521db7687a1", + "url": "https://api.github.com/repos/symfony/polyfill-php81/zipball/707403074c8ea6e2edaf8794b0157a0bfa52157a", + "reference": "707403074c8ea6e2edaf8794b0157a0bfa52157a", "shasum": "" }, "require": { @@ -6579,7 +6517,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "1.26-dev" + "dev-main": "1.27-dev" }, "thanks": { "name": "symfony/polyfill", @@ -6620,7 +6558,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-php81/tree/v1.26.0" + "source": "https://github.com/symfony/polyfill-php81/tree/v1.27.0" }, "funding": [ { @@ -6636,20 +6574,20 @@ "type": "tidelift" } ], - "time": "2022-05-24T11:49:31+00:00" + "time": "2022-11-03T14:55:06+00:00" }, { "name": "symfony/polyfill-uuid", - "version": "v1.26.0", + "version": "v1.27.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-uuid.git", - "reference": "a41886c1c81dc075a09c71fe6db5b9d68c79de23" + "reference": "f3cf1a645c2734236ed1e2e671e273eeb3586166" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-uuid/zipball/a41886c1c81dc075a09c71fe6db5b9d68c79de23", - "reference": "a41886c1c81dc075a09c71fe6db5b9d68c79de23", + "url": "https://api.github.com/repos/symfony/polyfill-uuid/zipball/f3cf1a645c2734236ed1e2e671e273eeb3586166", + "reference": "f3cf1a645c2734236ed1e2e671e273eeb3586166", "shasum": "" }, "require": { @@ -6664,7 +6602,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-main": "1.26-dev" + "dev-main": "1.27-dev" }, "thanks": { "name": "symfony/polyfill", @@ -6702,7 +6640,7 @@ "uuid" ], "support": { - "source": "https://github.com/symfony/polyfill-uuid/tree/v1.26.0" + "source": "https://github.com/symfony/polyfill-uuid/tree/v1.27.0" }, "funding": [ { @@ -6718,7 +6656,7 @@ "type": "tidelift" } ], - "time": "2022-05-24T11:49:31+00:00" + "time": "2022-11-03T14:55:06+00:00" }, { "name": "symfony/process", diff --git a/tests/Feature/ExampleTest.php b/tests/Feature/ExampleTest.php index 1eafba615..56853506c 100644 --- a/tests/Feature/ExampleTest.php +++ b/tests/Feature/ExampleTest.php @@ -14,7 +14,7 @@ class ExampleTest extends TestCase */ public function test_the_application_returns_a_successful_response() { - $response = $this->get('/'); + $response = $this->get('/admin/login'); $response->assertStatus(200); } From 2bb13fa93696d8c699738e94b568532b11d70f4a Mon Sep 17 00:00:00 2001 From: adamus1red Date: Thu, 10 Nov 2022 19:13:59 +0000 Subject: [PATCH 3/4] Add jitter data to InfluxDB feed (#136) --- app/Models/Result.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/app/Models/Result.php b/app/Models/Result.php index cb2f3bb6a..550796937 100644 --- a/app/Models/Result.php +++ b/app/Models/Result.php @@ -40,6 +40,7 @@ class Result extends Model */ protected $casts = [ 'scheduled' => 'boolean', + 'data' => 'array', 'created_at' => 'datetime', ]; @@ -53,10 +54,16 @@ public function formatForInfluxDB2() 'ping' => (float) $this->ping, 'download' => (int) $this->download, 'upload' => (int) $this->upload, + 'download_bits' => (int) $this->download * 8, + 'upload_bits' => (int) $this->upload * 8, + 'ping_jitter' => (float) $this->data['ping']['jitter'], + 'download_jitter' => (float) $this->data['download']['latency']['jitter'], + 'upload_jitter' => (float) $this->data['upload']['latency']['jitter'], 'server_id' => (int) $this->server_id, 'server_host' => $this->server_host, 'server_name' => $this->server_name, 'scheduled' => $this->scheduled, + 'packet_loss' => $this->data['packetLoss'], ]; } } From 67132b391265c315ff37b8c12fd67fe9037e4c4e Mon Sep 17 00:00:00 2001 From: Alex Justesen Date: Thu, 10 Nov 2022 14:41:46 -0500 Subject: [PATCH 4/4] Result created event (#138) --- app/Events/ResultCreated.php | 29 +++++ app/Filament/Pages/Settings/InfluxDbPage.php | 52 ++++---- .../Pages/Settings/ThresholdsPage.php | 21 +++- app/Listeners/Data/InfluxDb2Listener.php | 36 ++++++ app/Listeners/SpeedtestCompletedListener.php | 42 +++++++ .../Threshold/AbsoluteDownloadListener.php | 49 ++++++++ .../Threshold/AbsolutePingListener.php | 49 ++++++++ .../Threshold/AbsoluteUploadListener.php | 49 ++++++++ app/Models/Result.php | 10 ++ app/Observers/ResultObserver.php | 113 ------------------ app/Providers/EventServiceProvider.php | 17 ++- app/Settings/ThresholdSettings.php | 6 +- ...0_24_153411_create_thresholds_settings.php | 6 +- 13 files changed, 331 insertions(+), 148 deletions(-) create mode 100644 app/Events/ResultCreated.php create mode 100644 app/Listeners/Data/InfluxDb2Listener.php create mode 100644 app/Listeners/SpeedtestCompletedListener.php create mode 100644 app/Listeners/Threshold/AbsoluteDownloadListener.php create mode 100644 app/Listeners/Threshold/AbsolutePingListener.php create mode 100644 app/Listeners/Threshold/AbsoluteUploadListener.php delete mode 100644 app/Observers/ResultObserver.php diff --git a/app/Events/ResultCreated.php b/app/Events/ResultCreated.php new file mode 100644 index 000000000..02466c153 --- /dev/null +++ b/app/Events/ResultCreated.php @@ -0,0 +1,29 @@ +result = $result; + + $this->user = User::find(1); // find the admin user, this isn't ideal but oh well + } +} diff --git a/app/Filament/Pages/Settings/InfluxDbPage.php b/app/Filament/Pages/Settings/InfluxDbPage.php index e0eb777fb..29782304c 100644 --- a/app/Filament/Pages/Settings/InfluxDbPage.php +++ b/app/Filament/Pages/Settings/InfluxDbPage.php @@ -3,6 +3,7 @@ namespace App\Filament\Pages\Settings; use App\Settings\InfluxDbSettings; +use Closure; use Filament\Forms\Components\Grid; use Filament\Forms\Components\Section; use Filament\Forms\Components\TextInput; @@ -39,27 +40,38 @@ protected function getFormSchema(): array ->schema([ Toggle::make('v2_enabled') ->label('Enable') + ->reactive() ->columnSpan(2), - TextInput::make('v2_url') - ->label('URL') - ->placeholder('http://your-influxdb-instance') - ->maxLength(255) - ->columnSpan(['md' => 2]), - TextInput::make('v2_org') - ->label('Org') - ->maxLength(255) - ->columnSpan(1), - TextInput::make('v2_bucket') - ->placeholder('speedtest-tracker') - ->label('Bucket') - ->maxLength(255) - ->columnSpan(1), - TextInput::make('v2_token') - ->label('Token') - ->maxLength(255) - ->password() - ->disableAutocomplete() - ->columnSpan(['md' => 2]), + Grid::make([ + 'default' => 1, + ]) + ->hidden(fn (Closure $get) => $get('v2_enabled') !== true) + ->schema([ + TextInput::make('v2_url') + ->label('URL') + ->placeholder('http://your-influxdb-instance') + ->maxLength(255) + ->required(fn (Closure $get) => $get('v2_enabled') == true) + ->columnSpan(['md' => 2]), + TextInput::make('v2_org') + ->label('Org') + ->maxLength(255) + ->required(fn (Closure $get) => $get('v2_enabled') == true) + ->columnSpan(1), + TextInput::make('v2_bucket') + ->placeholder('speedtest-tracker') + ->label('Bucket') + ->maxLength(255) + ->required(fn (Closure $get) => $get('v2_enabled') == true) + ->columnSpan(1), + TextInput::make('v2_token') + ->label('Token') + ->maxLength(255) + ->password() + ->required(fn (Closure $get) => $get('v2_enabled') == true) + ->disableAutocomplete() + ->columnSpan(['md' => 2]), + ]), ]) ->compact() ->columns([ diff --git a/app/Filament/Pages/Settings/ThresholdsPage.php b/app/Filament/Pages/Settings/ThresholdsPage.php index 3a476c339..192784c70 100644 --- a/app/Filament/Pages/Settings/ThresholdsPage.php +++ b/app/Filament/Pages/Settings/ThresholdsPage.php @@ -56,18 +56,27 @@ protected function getFormSchema(): array TextInput::make('absolute_download') ->label('Download') ->hint('Mbps') - ->helperText('Leave empty to skip this metric.') - ->numeric(), + ->helperText('Set to zero to disable this metric.') + ->default(0) + ->minValue(0) + ->numeric() + ->required(), TextInput::make('absolute_upload') ->label('Upload') ->hint('Mbps') - ->helperText('Leave empty to skip this metric.') - ->numeric(), + ->helperText('Set to zero to disable this metric.') + ->default(0) + ->minValue(0) + ->numeric() + ->required(), TextInput::make('absolute_ping') ->label('Ping') ->hint('Ms') - ->helperText('Leave empty to skip this metric.') - ->numeric(), + ->helperText('Set to zero to disable this metric.') + ->default(0) + ->minValue(0) + ->numeric() + ->required(), ]) ->columns([ 'default' => 1, diff --git a/app/Listeners/Data/InfluxDb2Listener.php b/app/Listeners/Data/InfluxDb2Listener.php new file mode 100644 index 000000000..5a3d2a07c --- /dev/null +++ b/app/Listeners/Data/InfluxDb2Listener.php @@ -0,0 +1,36 @@ +influxDbSettings = new (InfluxDbSettings::class); + } + + /** + * Handle the event. + * + * @param \App\Events\ResultCreated $event + * @return void + */ + public function handle(ResultCreated $event) + { + if ($this->influxDbSettings->v2_enabled) { + SendDataToInfluxDbV2::dispatch($event->result, $this->influxDbSettings); + } + } +} diff --git a/app/Listeners/SpeedtestCompletedListener.php b/app/Listeners/SpeedtestCompletedListener.php new file mode 100644 index 000000000..57f42b24e --- /dev/null +++ b/app/Listeners/SpeedtestCompletedListener.php @@ -0,0 +1,42 @@ +notificationSettings = new (NotificationSettings::class); + } + + /** + * Handle the event. + * + * @param \App\Events\ResultCreated $event + * @return void + */ + public function handle(ResultCreated $event) + { + if (! $this->notificationSettings->database_enabled) { + return; + } + + if ($this->notificationSettings->database_on_speedtest_run) { + Notification::make() + ->title('Speedtest completed') + ->success() + ->sendToDatabase($event->user); + } + } +} diff --git a/app/Listeners/Threshold/AbsoluteDownloadListener.php b/app/Listeners/Threshold/AbsoluteDownloadListener.php new file mode 100644 index 000000000..88acf3191 --- /dev/null +++ b/app/Listeners/Threshold/AbsoluteDownloadListener.php @@ -0,0 +1,49 @@ +notificationSettings = new (NotificationSettings::class); + + $this->thresholdSettings = new (ThresholdSettings::class); + } + + /** + * Handle the event. + * + * @param \App\Events\ResultCreated $event + * @return void + */ + public function handle(ResultCreated $event) + { + if (! $this->thresholdSettings->absolute_enabled && ! $this->thresholdSettings->absolute_download) { + return; + } + + if (formatBits(formatBytesToBits($event->result->download), 2, false) < $this->thresholdSettings->absolute_download) { + Notification::make() + ->title('Threshold breached') + ->body('Speedtest #'.$event->result->id.' breached the download threshold of '.$this->thresholdSettings->absolute_download.'Mbps at '.formatBits(formatBytesToBits($event->result->download), 2, false).'Mbps.') + ->warning() + ->sendToDatabase($event->user); + } + } +} diff --git a/app/Listeners/Threshold/AbsolutePingListener.php b/app/Listeners/Threshold/AbsolutePingListener.php new file mode 100644 index 000000000..6ae66371f --- /dev/null +++ b/app/Listeners/Threshold/AbsolutePingListener.php @@ -0,0 +1,49 @@ +notificationSettings = new (NotificationSettings::class); + + $this->thresholdSettings = new (ThresholdSettings::class); + } + + /** + * Handle the event. + * + * @param \App\Events\ResultCreated $event + * @return void + */ + public function handle(ResultCreated $event) + { + if (! $this->thresholdSettings->absolute_enabled && ! $this->thresholdSettings->absolute_ping) { + return; + } + + if ($event->result->ping > $this->thresholdSettings->absolute_ping) { + Notification::make() + ->title('Threshold breached') + ->body('Speedtest #'.$event->result->id.' breached the ping threshold of '.$this->thresholdSettings->absolute_ping.'ms at '.$event->result->ping.'ms.') + ->warning() + ->sendToDatabase($event->user); + } + } +} diff --git a/app/Listeners/Threshold/AbsoluteUploadListener.php b/app/Listeners/Threshold/AbsoluteUploadListener.php new file mode 100644 index 000000000..2705bed68 --- /dev/null +++ b/app/Listeners/Threshold/AbsoluteUploadListener.php @@ -0,0 +1,49 @@ +notificationSettings = new (NotificationSettings::class); + + $this->thresholdSettings = new (ThresholdSettings::class); + } + + /** + * Handle the event. + * + * @param \App\Events\ResultCreated $event + * @return void + */ + public function handle(ResultCreated $event) + { + if (! $this->thresholdSettings->absolute_enabled && ! $this->thresholdSettings->absolute_upload) { + return; + } + + if (formatBits(formatBytesToBits($event->result->upload), 2, false) < $this->thresholdSettings->absolute_upload) { + Notification::make() + ->title('Threshold breached') + ->body('Speedtest #'.$event->result->id.' breached the upload threshold of '.$this->thresholdSettings->absolute_upload.'Mbps at '.formatBits(formatBytesToBits($event->result->upload), 2, false).'Mbps.') + ->warning() + ->sendToDatabase($event->user); + } + } +} diff --git a/app/Models/Result.php b/app/Models/Result.php index 550796937..1bc7eeb37 100644 --- a/app/Models/Result.php +++ b/app/Models/Result.php @@ -2,6 +2,7 @@ namespace App\Models; +use App\Events\ResultCreated; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; @@ -44,6 +45,15 @@ class Result extends Model 'created_at' => 'datetime', ]; + /** + * Event mapping for the model. + * + * @var array + */ + protected $dispatchesEvents = [ + 'created' => ResultCreated::class, + ]; + /** * The attributes to be passed to influxdb */ diff --git a/app/Observers/ResultObserver.php b/app/Observers/ResultObserver.php deleted file mode 100644 index bc0924db0..000000000 --- a/app/Observers/ResultObserver.php +++ /dev/null @@ -1,113 +0,0 @@ -influxDbSettings = new (InfluxDbSettings::class); - - $this->notificationSettings = new (NotificationSettings::class); - - $this->thresholdSettings = new (ThresholdSettings::class); - } - - /** - * Handle the Result "created" event. - * - * @param \App\Models\Result $result - * @return void - */ - public function created(Result $result) - { - $user = User::find(1); - - // Notifications - if ($this->notificationSettings->database_enabled) { - if ($this->notificationSettings->database_on_speedtest_run) { - Notification::make() - ->title('Speedtest Completed') - ->success() - ->sendToDatabase($user); - } - - if ($this->notificationSettings->database_on_threshold_failure && $this->thresholdSettings->absolute_enabled) { - Notification::make() - ->title('Speedtest Threshold Breached: '.$result->id) - ->warning() - ->sendToDatabase($user); - } - } - - // Send data to time series databases - if ($this->influxDbSettings->v2_enabled) { - SendDataToInfluxDbV2::dispatch($result, $this->influxDbSettings); - } - } - - /** - * Handle the Result "updated" event. - * - * @param \App\Models\Result $result - * @return void - */ - public function updated(Result $result) - { - // - } - - /** - * Handle the Result "deleted" event. - * - * @param \App\Models\Result $result - * @return void - */ - public function deleted(Result $result) - { - // - } - - /** - * Handle the Result "restored" event. - * - * @param \App\Models\Result $result - * @return void - */ - public function restored(Result $result) - { - // - } - - /** - * Handle the Result "force deleted" event. - * - * @param \App\Models\Result $result - * @return void - */ - public function forceDeleted(Result $result) - { - // - } -} diff --git a/app/Providers/EventServiceProvider.php b/app/Providers/EventServiceProvider.php index 9e8616a47..7774f28b8 100644 --- a/app/Providers/EventServiceProvider.php +++ b/app/Providers/EventServiceProvider.php @@ -2,8 +2,7 @@ namespace App\Providers; -use App\Models\Result; -use App\Observers\ResultObserver; +use App\Events\ResultCreated; use Illuminate\Auth\Events\Registered; use Illuminate\Auth\Listeners\SendEmailVerificationNotification; use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider; @@ -20,6 +19,18 @@ class EventServiceProvider extends ServiceProvider Registered::class => [ SendEmailVerificationNotification::class, ], + + ResultCreated::class => [ + \App\Listeners\SpeedtestCompletedListener::class, + + // Data listeners + \App\Listeners\Data\InfluxDb2Listener::class, + + // Threashold listeners + \App\Listeners\Threshold\AbsoluteDownloadListener::class, + \App\Listeners\Threshold\AbsoluteUploadListener::class, + \App\Listeners\Threshold\AbsolutePingListener::class, + ], ]; /** @@ -29,7 +40,7 @@ class EventServiceProvider extends ServiceProvider */ public function boot() { - Result::observe(ResultObserver::class); + // } /** diff --git a/app/Settings/ThresholdSettings.php b/app/Settings/ThresholdSettings.php index 308b41942..332b925db 100644 --- a/app/Settings/ThresholdSettings.php +++ b/app/Settings/ThresholdSettings.php @@ -8,11 +8,11 @@ class ThresholdSettings extends Settings { public bool $absolute_enabled; - public ?string $absolute_download; + public ?float $absolute_download; - public ?string $absolute_upload; + public ?float $absolute_upload; - public ?string $absolute_ping; + public ?float $absolute_ping; public static function group(): string { diff --git a/database/settings/2022_10_24_153411_create_thresholds_settings.php b/database/settings/2022_10_24_153411_create_thresholds_settings.php index 62a0ab807..9dbc9496d 100644 --- a/database/settings/2022_10_24_153411_create_thresholds_settings.php +++ b/database/settings/2022_10_24_153411_create_thresholds_settings.php @@ -7,8 +7,8 @@ class CreateThresholdsSettings extends SettingsMigration public function up(): void { $this->migrator->add('threshold.absolute_enabled', false); - $this->migrator->add('threshold.absolute_download', null); - $this->migrator->add('threshold.absolute_upload', null); - $this->migrator->add('threshold.absolute_ping', null); + $this->migrator->add('threshold.absolute_download', 0); + $this->migrator->add('threshold.absolute_upload', 0); + $this->migrator->add('threshold.absolute_ping', 0); } }