Skip to content

[1.x] Pint #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Feb 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
.editorconfig export-ignore
.gitattributes export-ignore
.gitignore export-ignore
.styleci.yml export-ignore
CHANGELOG.md export-ignore
phpunit.xml.dist export-ignore
UPGRADE.md export-ignore
7 changes: 7 additions & 0 deletions .github/workflows/coding-standards.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
name: fix code styling

on: [push]

jobs:
lint:
uses: laravel/.github/.github/workflows/coding-standards.yml@main
2 changes: 1 addition & 1 deletion config/pulse.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
'path' => env('PULSE_PATH', 'pulse'),

'middleware' => [
'web'
'web',
],

// The name that will appear in the dashboard after running the `pulse:check` command.
Expand Down
45 changes: 22 additions & 23 deletions src/Pulse.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public function servers()
'cpu' => (int) $server['cpu'],
'memory_used' => (int) $server['memory_used'],
'memory_total' => (int) $server['memory_total'],
'storage' => json_decode($server['storage'])
'storage' => json_decode($server['storage']),
])
->values();

Expand All @@ -44,7 +44,7 @@ public function userRequestCounts()
RedisAdapter::zunionstore(
'pulse_user_request_counts:7-day',
collect(range(0, 6))
->map(fn ($days) => 'pulse_user_request_counts:' . now()->subDays($days)->format('Y-m-d'))
->map(fn ($days) => 'pulse_user_request_counts:'.now()->subDays($days)->format('Y-m-d'))
->toArray()
);

Expand Down Expand Up @@ -72,25 +72,25 @@ public function slowEndpoints()
RedisAdapter::zunionstore(
'pulse_slow_endpoint_request_counts:7-day',
collect(range(0, 6))
->map(fn ($days) => 'pulse_slow_endpoint_request_counts:' . now()->subDays($days)->format('Y-m-d'))
->map(fn ($days) => 'pulse_slow_endpoint_request_counts:'.now()->subDays($days)->format('Y-m-d'))
->toArray(),
'SUM'
'SUM'
);

RedisAdapter::zunionstore(
'pulse_slow_endpoint_total_durations:7-day',
collect(range(0, 6))
->map(fn ($days) => 'pulse_slow_endpoint_total_durations:' . now()->subDays($days)->format('Y-m-d'))
->map(fn ($days) => 'pulse_slow_endpoint_total_durations:'.now()->subDays($days)->format('Y-m-d'))
->toArray(),
'SUM'
'SUM'
);

RedisAdapter::zunionstore(
'pulse_slow_endpoint_slowest_durations:7-day',
collect(range(0, 6))
->map(fn ($days) => 'pulse_slow_endpoint_slowest_durations:' . now()->subDays($days)->format('Y-m-d'))
->map(fn ($days) => 'pulse_slow_endpoint_slowest_durations:'.now()->subDays($days)->format('Y-m-d'))
->toArray(),
'MAX'
'MAX'
);

$requestCounts = RedisAdapter::zrevrange('pulse_slow_endpoint_request_counts:7-day', 0, -1, true);
Expand Down Expand Up @@ -119,9 +119,9 @@ public function usersExperiencingSlowEndpoints()
RedisAdapter::zunionstore(
'pulse_slow_endpoint_user_counts:7-day',
collect(range(0, 6))
->map(fn ($days) => 'pulse_slow_endpoint_user_counts:' . now()->subDays($days)->format('Y-m-d'))
->map(fn ($days) => 'pulse_slow_endpoint_user_counts:'.now()->subDays($days)->format('Y-m-d'))
->toArray(),
'SUM'
'SUM'
);

$userCounts = collect(RedisAdapter::zrevrange('pulse_slow_endpoint_user_counts:7-day', 0, -1, true));
Expand All @@ -148,25 +148,25 @@ public function slowQueries()
RedisAdapter::zunionstore(
'pulse_slow_query_execution_counts:7-day',
collect(range(0, 6))
->map(fn ($days) => 'pulse_slow_query_execution_counts:' . now()->subDays($days)->format('Y-m-d'))
->map(fn ($days) => 'pulse_slow_query_execution_counts:'.now()->subDays($days)->format('Y-m-d'))
->toArray(),
'SUM'
'SUM'
);

RedisAdapter::zunionstore(
'pulse_slow_query_total_durations:7-day',
collect(range(0, 6))
->map(fn ($days) => 'pulse_slow_query_total_durations:' . now()->subDays($days)->format('Y-m-d'))
->map(fn ($days) => 'pulse_slow_query_total_durations:'.now()->subDays($days)->format('Y-m-d'))
->toArray(),
'SUM'
'SUM'
);

RedisAdapter::zunionstore(
'pulse_slow_query_slowest_durations:7-day',
collect(range(0, 6))
->map(fn ($days) => 'pulse_slow_query_slowest_durations:' . now()->subDays($days)->format('Y-m-d'))
->map(fn ($days) => 'pulse_slow_query_slowest_durations:'.now()->subDays($days)->format('Y-m-d'))
->toArray(),
'MAX'
'MAX'
);

$executionCounts = RedisAdapter::zrevrange('pulse_slow_query_execution_counts:7-day', 0, -1, true);
Expand All @@ -175,7 +175,6 @@ public function slowQueries()

return collect($executionCounts)
->map(function ($executionCount, $sql) use ($totalDurations, $slowestDurations) {

return [
'sql' => $sql,
'execution_count' => (int) $executionCount,
Expand All @@ -189,11 +188,11 @@ public function slowQueries()
public function cacheStats()
{
$hits = collect(range(0, 6))
->map(fn ($days) => RedisAdapter::get('pulse_cache_hits:' . now()->subDays($days)->format('Y-m-d')))
->map(fn ($days) => RedisAdapter::get('pulse_cache_hits:'.now()->subDays($days)->format('Y-m-d')))
->sum();

$misses = collect(range(0, 6))
->map(fn ($days) => RedisAdapter::get('pulse_cache_misses:' . now()->subDays($days)->format('Y-m-d')))
->map(fn ($days) => RedisAdapter::get('pulse_cache_misses:'.now()->subDays($days)->format('Y-m-d')))
->sum();

$total = $hits + $misses;
Expand All @@ -216,17 +215,17 @@ public function exceptions()
RedisAdapter::zunionstore(
'pulse_exception_counts:7-day',
collect(range(0, 6))
->map(fn ($days) => 'pulse_exception_counts:' . now()->subDays($days)->format('Y-m-d'))
->map(fn ($days) => 'pulse_exception_counts:'.now()->subDays($days)->format('Y-m-d'))
->toArray(),
'SUM'
'SUM'
);

RedisAdapter::zunionstore(
'pulse_exception_last_occurrences:7-day',
collect(range(0, 6))
->map(fn ($days) => 'pulse_exception_last_occurrences:' . now()->subDays($days)->format('Y-m-d'))
->map(fn ($days) => 'pulse_exception_last_occurrences:'.now()->subDays($days)->format('Y-m-d'))
->toArray(),
'MAX'
'MAX'
);

$exceptionCounts = RedisAdapter::zrevrange('pulse_exception_counts:7-day', 0, -1, true);
Expand Down
2 changes: 1 addition & 1 deletion src/PulseServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
use Illuminate\Support\Facades\Event;
use Illuminate\Support\Facades\Route;
use Illuminate\Support\ServiceProvider;
use Laravel\Pulse\View\Components\Pulse as PulseComponent;
use Laravel\Pulse\Commands\CheckCommand;
use Laravel\Pulse\Contracts\ShouldNotReportUsage;
use Laravel\Pulse\Handlers\HandleCacheHit;
Expand All @@ -28,6 +27,7 @@
use Laravel\Pulse\Http\Livewire\SlowEndpoints;
use Laravel\Pulse\Http\Livewire\SlowQueries;
use Laravel\Pulse\Http\Livewire\Usage;
use Laravel\Pulse\View\Components\Pulse as PulseComponent;
use Livewire\Livewire;
use Throwable;

Expand Down