From 91d228240a88302cc02f09816229d004881bf6ea Mon Sep 17 00:00:00 2001 From: Luan Freitas <33601626+luanfreitasdev@users.noreply.github.com> Date: Thu, 7 Mar 2024 21:52:53 -0300 Subject: [PATCH] Fix view:cache bug (#1452) * Fix view:cache bug * Add fail-fast * Add fail-fast --- .github/workflows/code-style.yml | 1 + .github/workflows/cypress.yml | 1 + .github/workflows/mysql.yml | 1 + .github/workflows/pgsql.yml | 1 + .github/workflows/phpstan.yml | 1 + .github/workflows/sqlite.yml | 1 + .../views/livewire/performance-card.blade.php | 87 -------------- src/Livewire/PerformanceCard.php | 109 ++++++++++++++++-- 8 files changed, 103 insertions(+), 99 deletions(-) delete mode 100644 resources/views/livewire/performance-card.blade.php diff --git a/.github/workflows/code-style.yml b/.github/workflows/code-style.yml index 9fa43b71..a9b0804f 100644 --- a/.github/workflows/code-style.yml +++ b/.github/workflows/code-style.yml @@ -17,6 +17,7 @@ jobs: build: runs-on: ubuntu-latest strategy: + fail-fast: false matrix: php: [ 8.2, 8.1 ] laravel: [ 11.*, 10.* ] diff --git a/.github/workflows/cypress.yml b/.github/workflows/cypress.yml index 208beead..75a94832 100644 --- a/.github/workflows/cypress.yml +++ b/.github/workflows/cypress.yml @@ -38,6 +38,7 @@ jobs: options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 strategy: + fail-fast: false matrix: php: [ 8.2 ] laravel: [ 10.* ] diff --git a/.github/workflows/mysql.yml b/.github/workflows/mysql.yml index a5bbea2a..fa81113f 100644 --- a/.github/workflows/mysql.yml +++ b/.github/workflows/mysql.yml @@ -28,6 +28,7 @@ jobs: options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 strategy: + fail-fast: false matrix: php: [ 8.2, 8.1 ] laravel: [ 11.*, 10.* ] diff --git a/.github/workflows/pgsql.yml b/.github/workflows/pgsql.yml index 0cf98624..a56294e1 100644 --- a/.github/workflows/pgsql.yml +++ b/.github/workflows/pgsql.yml @@ -29,6 +29,7 @@ jobs: options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 strategy: + fail-fast: false matrix: php: [ 8.2, 8.1 ] laravel: [ 11.*, 10.* ] diff --git a/.github/workflows/phpstan.yml b/.github/workflows/phpstan.yml index 604632c9..214503bf 100644 --- a/.github/workflows/phpstan.yml +++ b/.github/workflows/phpstan.yml @@ -17,6 +17,7 @@ jobs: build: runs-on: ubuntu-latest strategy: + fail-fast: false matrix: php: [ 8.2 ] laravel: [ 11.*, 10.* ] diff --git a/.github/workflows/sqlite.yml b/.github/workflows/sqlite.yml index abd32459..a7fb9542 100644 --- a/.github/workflows/sqlite.yml +++ b/.github/workflows/sqlite.yml @@ -17,6 +17,7 @@ jobs: build: runs-on: ubuntu-latest strategy: + fail-fast: false matrix: php: [ 8.2, 8.1 ] laravel: [ 11.*, 10.* ] diff --git a/resources/views/livewire/performance-card.blade.php b/resources/views/livewire/performance-card.blade.php deleted file mode 100644 index e9803288..00000000 --- a/resources/views/livewire/performance-card.blade.php +++ /dev/null @@ -1,87 +0,0 @@ - - - - - - -
- @if ($records->isEmpty()) - - @elseif (!$config['enabled']) -
- -

- PowerGrid metering has been disabled. -

-
- - @else -
-
-
- {{ round($averageRetrieveData, 2) }} ms -
- - - retrieve Data - -
-
-
- {{ round($averageQueriesTime, 2) }} ms -
- - - query Time - -
-
-
- - - - - - - - - Table - Time - Query Time - Total Queries - Created at - - - - @foreach ($records as $record) - - - - - {{ data_get($record, 'tableName') }} - - - - {{ data_get($record, 'retrieveDataInMs') }} ms - - - {{ data_get($record, 'queriesTimeInMs') }} ms - - - {{ count(data_get($record, 'queries') ) }} - - - @php - $createdAt = \Illuminate\Support\Carbon::createFromTimestamp(data_get($record, 'timestamp')); - @endphp - {{ $createdAt->diffForHumans() }} - - - @endforeach - - - @endif -
-
-
-
diff --git a/src/Livewire/PerformanceCard.php b/src/Livewire/PerformanceCard.php index 86162bc8..2d24e9e0 100644 --- a/src/Livewire/PerformanceCard.php +++ b/src/Livewire/PerformanceCard.php @@ -2,15 +2,14 @@ namespace PowerComponents\LivewirePowerGrid\Livewire; -use Illuminate\Contracts\View\View; -use Illuminate\Support\Facades\Config; +use Illuminate\Support\Facades\{Blade, Config}; use Livewire\Attributes\Lazy; use PowerComponents\LivewirePowerGrid\Recorders\PowerGridPerformanceRecorder; #[Lazy] class PerformanceCard extends \Laravel\Pulse\Livewire\Card { - public function render(): View + public function render() { $config = Config::get('pulse.recorders.' . PowerGridPerformanceRecorder::class); @@ -40,14 +39,100 @@ public function render(): View $averageQueriesTime = $records->avg(fn ($item) => $item->queriesTimeInMs); } - return view( - 'livewire-powergrid::livewire.performance-card', - compact( - 'records', - 'averageQueriesTime', - 'averageRetrieveData', - 'config' - ) - ); + return Blade::render(<< + + + + + +
+ @if (\$records->isEmpty()) + + @elseif (!\$enabled) +
+ +

+ PowerGrid metering has been disabled. +

+
+ @else +
+
+
+ {{ round(\$averageRetrieveData, 2) }} ms +
+ + + retrieve Data + +
+
+
+ {{ round(\$averageQueriesTime, 2) }} ms +
+ + + query Time + +
+
+
+ + + + + + + + + Table + Time + Query Time + Total Queries + Created at + + + + @foreach (\$records as \$record) + + + + + {{ data_get(\$record, 'tableName') }} + + + + {{ data_get(\$record, 'retrieveDataInMs') }} ms + + + {{ data_get(\$record, 'queriesTimeInMs') }} ms + + + {{ count(data_get(\$record, 'queries') ) }} + + + + {{ \\Illuminate\Support\Carbon::createFromTimestamp(data_get(\$record, 'timestamp'))->diffForHumans() }} + + + @endforeach + + +
+ @endif +
+
+ + blade, [ + 'cols' => $this->cols, + 'rows' => $this->rows, + 'class' => $this->class, + 'expand' => $this->expand, + 'averageRetrieveData' => $averageRetrieveData, + 'averageQueriesTime' => $averageQueriesTime, + 'records' => $records, + 'enabled' => $config['enabled'], + ]); } }