Skip to content

Commit

Permalink
Adding ISP value to result, export, notifications & influxdb (#1515)
Browse files Browse the repository at this point in the history
Co-authored-by: Alex Justesen <[email protected]>
  • Loading branch information
svenvg93 and alexjustesen authored Jun 11, 2024
1 parent f4a3deb commit 6af99b5
Show file tree
Hide file tree
Showing 17 changed files with 33 additions and 5 deletions.
6 changes: 6 additions & 0 deletions app/Filament/Exports/ResultExporter.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ public static function getColumns(): array
return $record->ip_address;
})
->enabledByDefault(false),
ExportColumn::make('isp')
->label('ISP')
->state(function (Result $record): ?string {
return $record->isp;
})
->enabledByDefault(false),
ExportColumn::make('service'),
ExportColumn::make('server_id')
->label('Server ID')
Expand Down
10 changes: 10 additions & 0 deletions app/Filament/Resources/ResultResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@ public static function form(Form $form): Form
Forms\Components\Placeholder::make('server_id')
->label('Server ID')
->content(fn (Result $result): ?string => $result->server_id),
Forms\Components\Placeholder::make('isp')
->label('ISP')
->content(fn (Result $result): ?string => $result->isp),
Forms\Components\Placeholder::make('server_host')
->content(fn (Result $result): ?string => $result->server_host),
Forms\Components\Checkbox::make('scheduled'),
Expand Down Expand Up @@ -138,6 +141,13 @@ public static function table(Table $table): Table
->sortable(query: function (Builder $query, string $direction): Builder {
return $query->orderBy('data->server->id', $direction);
}),
Tables\Columns\TextColumn::make('data.isp')
->label('ISP')
->toggleable()
->toggledHiddenByDefault()
->sortable(query: function (Builder $query, string $direction): Builder {
return $query->orderBy('data->isp', $direction);
}),
Tables\Columns\TextColumn::make('data.server.name')
->toggleable()
->sortable(query: function (Builder $query, string $direction): Builder {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public function handle(SpeedtestCompleted $event): void
'service' => Str::title($event->result->service),
'serverName' => $event->result->server_name,
'serverId' => $event->result->server_id,
'isp' => $event->result->isp,
'ping' => round($event->result->ping).' ms',
'download' => Number::toBitRate(bits: $event->result->download_bits, precision: 2),
'upload' => Number::toBitRate(bits: $event->result->upload_bits, precision: 2),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ public function handle(SpeedtestCompleted $event): void
'service' => Str::title($event->result->service),
'serverName' => $event->result->server_name,
'serverId' => $event->result->server_id,
'isp' => $event->result->isp,
'metrics' => $failed,
'url' => url('/admin/results'),
])->render(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public function handle(SpeedtestCompleted $event): void
'service' => Str::title($event->result->service),
'serverName' => $event->result->server_name,
'serverId' => $event->result->server_id,
'isp' => $event->result->isp,
'ping' => round($event->result->ping).' ms',
'download' => Number::toBitRate(bits: $event->result->download_bits, precision: 2),
'upload' => Number::toBitRate(bits: $event->result->upload_bits, precision: 2),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ public function handle(SpeedtestCompleted $event): void
'service' => Str::title($event->result->service),
'serverName' => $event->result->server_name,
'serverId' => $event->result->server_id,
'isp' => $event->result->isp,
'metrics' => $failed,
'url' => url('/admin/results'),
])->render();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public function handle(SpeedtestCompleted $event): void
->payload([
'result_id' => $event->result->id,
'site_name' => config('app.name'),
'isp' => $event->result->isp,
'ping' => $event->result->ping,
'download' => $event->result->downloadBits,
'upload' => $event->result->uploadBits,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ public function handle(SpeedtestCompleted $event): void
->payload([
'result_id' => $event->result->id,
'site_name' => config('app.name'),
'isp' => $event->result->isp,
'metrics' => $failed,
'url' => url('/admin/results'),
])
Expand Down
1 change: 1 addition & 0 deletions app/Mail/SpeedtestCompletedMail.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ public function content(): Content
'service' => Str::title($this->result->service),
'serverName' => $this->result->server_name,
'serverId' => $this->result->server_id,
'isp' => $event->result->isp,
'ping' => round($this->result->ping, 2).' ms',
'download' => Number::toBitRate(bits: $this->result->download_bits, precision: 2),
'upload' => Number::toBitRate(bits: $this->result->upload_bits, precision: 2),
Expand Down
1 change: 1 addition & 0 deletions app/Mail/SpeedtestThresholdMail.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ public function content(): Content
'service' => Str::title($this->result->service),
'serverName' => $this->result->server_name,
'serverId' => $this->result->server_id,
'isp' => $event->result->isp,
'url' => url('/admin/results'),
'metrics' => $this->metrics,
],
Expand Down
1 change: 1 addition & 0 deletions app/Models/Result.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ public function formatForInfluxDB2()
'upload_latency_low' => $this->upload_latency_low,
'upload_latency_high' => $this->upload_latency_high,
'server_id' => $this?->server_id,
'isp' => $this?->isp,
'server_host' => $this?->server_host,
'server_name' => $this?->server_name,
'scheduled' => $this->scheduled,
Expand Down
1 change: 1 addition & 0 deletions resources/views/discord/speedtest-completed.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

- **Server name:** {{ $serverName }}
- **Server ID:** {{ $serverId }}
- **ISP:** {{ $isp }}
- **Ping:** {{ $ping }}
- **Download:** {{ $download }}
- **Upload:** {{ $upload }}
Expand Down
2 changes: 1 addition & 1 deletion resources/views/discord/speedtest-threshold.blade.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
**Speedtest Threshold Breached - #{{ $id }}**

A new speedtest was completed using **{{ $service }}** but a threshold was breached.
A new speedtest was completed using **{{ $service }}** on **{{ $isp }}** but a threshold was breached.

@foreach ($metrics as $item)
- **{{ $item['name'] }}** {{ $item['threshold'] }}: {{ $item['value'] }}
Expand Down
1 change: 1 addition & 0 deletions resources/views/emails/speedtest-completed.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
|:------------|---------------------------:|
| Server name | {{ $serverName }} |
| Server ID | {{ $serverId }} |
| ISP | {{ $isp }} |
| Ping | {{ $ping }} |
| Download | {{ $download }} |
| Upload | {{ $upload }} |
Expand Down
2 changes: 1 addition & 1 deletion resources/views/emails/speedtest-threshold.blade.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<x-mail::message>
# Speedtest Threshold Breached - #{{ $id }}

A new speedtest was completed using **{{ $service }}** but a threshold was breached.
A new speedtest was completed using **{{ $service }}** on **{{ $isp }}** but a threshold was breached.

<x-mail::table>
| **Metric** | **Threshold** | **Value** |
Expand Down
1 change: 1 addition & 0 deletions resources/views/telegram/speedtest-completed.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

- *Server name:* {{ $serverName }}
- *Server ID:* {{ $serverId }}
- **ISP:** {{ $isp }}
- *Ping:* {{ $ping }}
- *Download:* {{ $download }}
- *Upload:* {{ $upload }}
Expand Down
6 changes: 3 additions & 3 deletions resources/views/telegram/speedtest-threshold.blade.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
*Speedtest Threshold Breached - #{{ $id }}*
**Speedtest Threshold Breached - #{{ $id }}**

A new speedtest was completed using *{{ $service }}* but a threshold was breached.
A new speedtest was completed using **{{ $service }}** on **{{ $isp }}** but a threshold was breached.

@foreach ($metrics as $item)
- *{{ $item['name'] }}* {{ $item['threshold'] }}: {{ $item['value'] }}
- **{{ $item['name'] }}** {{ $item['threshold'] }}: {{ $item['value'] }}
@endforeach
- **URL:** {{ $url }}

0 comments on commit 6af99b5

Please sign in to comment.