From f5bddca70c7c4541d0d011c185b80caa20db6525 Mon Sep 17 00:00:00 2001 From: Romulus21 Date: Sat, 25 May 2024 16:03:48 +0200 Subject: [PATCH] update pulse --- composer.json | 2 +- composer.lock | 6 +- .../2023_06_07_000001_create_pulse_tables.php | 84 +++++++++++++++++++ .../views/vendor/pulse/dashboard.blade.php | 19 +++++ 4 files changed, 106 insertions(+), 5 deletions(-) create mode 100644 database/migrations/2023_06_07_000001_create_pulse_tables.php create mode 100644 resources/views/vendor/pulse/dashboard.blade.php diff --git a/composer.json b/composer.json index 668722f..3f6eda7 100644 --- a/composer.json +++ b/composer.json @@ -8,7 +8,7 @@ "php": "^8.3", "guzzlehttp/guzzle": "^7.2", "laravel/framework": "^10.10", - "laravel/pulse": "^1.0@beta", + "laravel/pulse": "^1.2", "laravel/sanctum": "^3.2", "laravel/tinker": "^2.8" }, diff --git a/composer.lock b/composer.lock index 5d69339..4cc54ea 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "254033ae1a2f1cc912a3d82d267a30cf", + "content-hash": "0f6e27f14c38c1765230c04449eba57c", "packages": [ { "name": "brick/math", @@ -9262,9 +9262,7 @@ ], "aliases": [], "minimum-stability": "beta", - "stability-flags": { - "laravel/pulse": 10 - }, + "stability-flags": [], "prefer-stable": true, "prefer-lowest": false, "platform": { diff --git a/database/migrations/2023_06_07_000001_create_pulse_tables.php b/database/migrations/2023_06_07_000001_create_pulse_tables.php new file mode 100644 index 0000000..5d194e2 --- /dev/null +++ b/database/migrations/2023_06_07_000001_create_pulse_tables.php @@ -0,0 +1,84 @@ +shouldRun()) { + return; + } + + Schema::create('pulse_values', function (Blueprint $table) { + $table->id(); + $table->unsignedInteger('timestamp'); + $table->string('type'); + $table->mediumText('key'); + match ($this->driver()) { + 'mariadb', 'mysql' => $table->char('key_hash', 16)->charset('binary')->virtualAs('unhex(md5(`key`))'), + 'pgsql' => $table->uuid('key_hash')->storedAs('md5("key")::uuid'), + 'sqlite' => $table->string('key_hash'), + }; + $table->mediumText('value'); + + $table->index('timestamp'); // For trimming... + $table->index('type'); // For fast lookups and purging... + $table->unique(['type', 'key_hash']); // For data integrity and upserts... + }); + + Schema::create('pulse_entries', function (Blueprint $table) { + $table->id(); + $table->unsignedInteger('timestamp'); + $table->string('type'); + $table->mediumText('key'); + match ($this->driver()) { + 'mariadb', 'mysql' => $table->char('key_hash', 16)->charset('binary')->virtualAs('unhex(md5(`key`))'), + 'pgsql' => $table->uuid('key_hash')->storedAs('md5("key")::uuid'), + 'sqlite' => $table->string('key_hash'), + }; + $table->bigInteger('value')->nullable(); + + $table->index('timestamp'); // For trimming... + $table->index('type'); // For purging... + $table->index('key_hash'); // For mapping... + $table->index(['timestamp', 'type', 'key_hash', 'value']); // For aggregate queries... + }); + + Schema::create('pulse_aggregates', function (Blueprint $table) { + $table->id(); + $table->unsignedInteger('bucket'); + $table->unsignedMediumInteger('period'); + $table->string('type'); + $table->mediumText('key'); + match ($this->driver()) { + 'mariadb', 'mysql' => $table->char('key_hash', 16)->charset('binary')->virtualAs('unhex(md5(`key`))'), + 'pgsql' => $table->uuid('key_hash')->storedAs('md5("key")::uuid'), + 'sqlite' => $table->string('key_hash'), + }; + $table->string('aggregate'); + $table->decimal('value', 20, 2); + $table->unsignedInteger('count')->nullable(); + + $table->unique(['bucket', 'period', 'type', 'aggregate', 'key_hash']); // Force "on duplicate update"... + $table->index(['period', 'bucket']); // For trimming... + $table->index('type'); // For purging... + $table->index(['period', 'type', 'aggregate', 'bucket']); // For aggregate queries... + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::dropIfExists('pulse_values'); + Schema::dropIfExists('pulse_entries'); + Schema::dropIfExists('pulse_aggregates'); + } +}; diff --git a/resources/views/vendor/pulse/dashboard.blade.php b/resources/views/vendor/pulse/dashboard.blade.php new file mode 100644 index 0000000..6a95bb1 --- /dev/null +++ b/resources/views/vendor/pulse/dashboard.blade.php @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + + +