Skip to content

Commit 9d6481d

Browse files
authored
[1.x] Cleanup (#356)
* Remove TODOs * Make SQL highlighting configurable at the view layer * Update upgrade guide * Formatting * Include throttle information
1 parent be1fae9 commit 9d6481d

File tree

6 files changed

+12
-24
lines changed

6 files changed

+12
-24
lines changed

UPGRADE.md

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,8 @@
22

33
# Beta to 1.x
44

5-
## Required
6-
7-
- [Added a `pulse.recorders.SlowQueries.highlight` configuration option](https://github.com/laravel/pulse/pull/172). You should update your configuration to match.
8-
- [`pulse.ingest.trim_lottery` configuration key was renamed to `pulse.ingest.trim.lottery`](https://github.com/laravel/pulse/pull/184). You should update your configuration to match.
9-
- [Added a `pulse.ingest.trim.keep` configuration option](https://github.com/laravel/pulse/pull/184). You should update your configuration to match.
10-
11-
## Optional
12-
5+
- [SQL highlighting configuration was moved to the dashboard component](https://github.com/laravel/pulse/pull/356). This is required if you are disabling SQL highlighting.
136
- [Auto-incrementing IDs were added to Pulse's tables](https://github.com/laravel/pulse/pull/142). This is recommended if you are using a configuration that requires tables to have a unique key on every table, e.g., PlanetScale.
14-
- [The TEXT columns were made MEDIUMTEXT columns in the `pulse_` tables](https://github.com/laravel/pulse/pull/185). Recommend to support longer content values, such as long SQL queries.
15-
- [Pulse's migrations are now published to the application](https://github.com/laravel/pulse/pull/81). Recommend so you can have complete control over the migrations as needed.
7+
- [The TEXT columns were made MEDIUMTEXT columns in the `pulse_` tables](https://github.com/laravel/pulse/pull/185). This is recommend to support longer content values, such as long SQL queries.
8+
- [Pulse's migrations are now published to the application](https://github.com/laravel/pulse/pull/81). This is recommend so you can have complete control over the migrations as needed.
9+
- [`pulse:check` now dispatches events roughly every second](https://github.com/laravel/pulse/pull/314). It is recommended to use the new `throttle` function when performing work on specific intervals.

config/pulse.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,6 @@
195195
'sample_rate' => env('PULSE_SLOW_QUERIES_SAMPLE_RATE', 1),
196196
'threshold' => env('PULSE_SLOW_QUERIES_THRESHOLD', 1000),
197197
'location' => env('PULSE_SLOW_QUERIES_LOCATION', true),
198-
'highlighting' => env('PULSE_SLOW_QUERIES_HIGHLIGHTING', true),
199198
'max_query_length' => env('PULSE_SLOW_QUERIES_MAX_QUERY_LENGTH', null),
200199
'ignore' => [
201200
'/(["`])pulse_[\w]+?\1/', // Pulse tables...

resources/views/livewire/slow-queries.blade.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
use \Doctrine\SqlFormatter\HtmlHighlighter;
33
use \Doctrine\SqlFormatter\SqlFormatter;
44
5-
if ($config['highlighting']) {
5+
if (! $this->disableHighlighting) {
66
$sqlFormatter = new SqlFormatter(new HtmlHighlighter([
77
HtmlHighlighter::HIGHLIGHT_RESERVED => 'class="font-semibold"',
88
HtmlHighlighter::HIGHLIGHT_QUOTE => 'class="text-purple-200"',
@@ -62,7 +62,7 @@
6262
<x-pulse::td class="!p-0 truncate max-w-[1px]">
6363
<div class="relative">
6464
<div class="bg-gray-700 dark:bg-gray-800 py-4 rounded-md text-gray-100 block text-xs whitespace-nowrap overflow-x-auto [scrollbar-color:theme(colors.gray.500)_transparent] [scrollbar-width:thin]">
65-
<code class="px-3">{!! $config['highlighting'] ? $sqlFormatter->highlight($query->sql) : $query->sql !!}</code>
65+
<code class="px-3">{!! $this->disableHighlighting ? $query->sql : $sqlFormatter->highlight($query->sql) !!}</code>
6666
@if ($query->location)
6767
<p class="px-3 mt-3 text-xs leading-none text-gray-400 dark:text-gray-500">
6868
{{ $query->location }}

src/Livewire/SlowQueries.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ class SlowQueries extends Card
2323
#[Url(as: 'slow-queries')]
2424
public string $orderBy = 'slowest';
2525

26+
/**
27+
* Indicates that SQL highlighting should be disabled.
28+
*/
29+
public bool $disableHighlighting = false;
30+
2631
/**
2732
* Render the component.
2833
*/
@@ -52,11 +57,7 @@ public function render(): Renderable
5257
return View::make('pulse::livewire.slow-queries', [
5358
'time' => $time,
5459
'runAt' => $runAt,
55-
'config' => [
56-
// TODO remove fallback when tagging v1
57-
'highlighting' => true,
58-
...Config::get('pulse.recorders.'.SlowQueriesRecorder::class),
59-
],
60+
'config' => Config::get('pulse.recorders.'.SlowQueriesRecorder::class),
6061
'slowQueries' => $slowQueries,
6162
]);
6263
}

src/Pulse.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,6 @@ public function ingest(): int
307307
return $entries->count();
308308
}) ?? 0;
309309

310-
// TODO remove fallback when tagging v1
311310
$odds = $this->app->make('config')->get('pulse.ingest.trim.lottery') ?? $this->app->make('config')->get('pulse.ingest.trim_lottery');
312311

313312
Lottery::odds(...$odds)
@@ -350,7 +349,6 @@ protected function ingestWhenOverBufferSize(): void
350349
return;
351350
}
352351

353-
// TODO remove fallback when tagging v1
354352
$buffer = $this->app->make('config')->get('pulse.ingest.buffer') ?? 5_000;
355353

356354
if (($this->entries->count() + $this->lazy->count()) > $buffer) {

src/Storage/DatabaseStorage.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -135,10 +135,6 @@ public function trim(): void
135135
->where('timestamp', '<=', $now->subWeek()->getTimestamp())
136136
->delete();
137137

138-
// TODO: Run a single delete with multiple grouped conditions?
139-
// E.g. where (`period` = 60 AND `bucket` <= 1623072000) or (`period` = 360 AND `bucket` <= 1623046800)
140-
// 1 query instead of 5
141-
142138
$this->connection()
143139
->table('pulse_aggregates')
144140
->distinct()

0 commit comments

Comments
 (0)