Skip to content
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
4 changes: 3 additions & 1 deletion app/Actions/Influxdb/v2/BuildPointData.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ public function handle(Result $result): Point
->addField('upload_latency_avg', Number::castToType(Arr::get($result->data, 'upload.latency.iqm'), 'float'))
->addField('upload_latency_high', Number::castToType(Arr::get($result->data, 'upload.latency.high'), 'float'))
->addField('upload_latency_low', Number::castToType(Arr::get($result->data, 'upload.latency.low'), 'float'))
->addField('packet_loss', Number::castToType(Arr::get($result->data, 'packetLoss'), 'float'));
->addField('packet_loss', Number::castToType(Arr::get($result->data, 'packetLoss'), 'float'))
->addField('downloaded_bytes', Number::castToType($result->downloaded_bytes, 'int'))
->addField('uploaded_bytes', Number::castToType($result->uploaded_bytes, 'int'));

return $point;
}
Expand Down
4 changes: 4 additions & 0 deletions app/Filament/Exports/ResultExporter.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,10 @@ public static function getColumns(): array
return $record->download_latency_iqm;
})
->enabledByDefault(false),
ExportColumn::make('downloaded_bytes')
->enabledByDefault(false),
ExportColumn::make('uploaded_bytes')
->enabledByDefault(false),
ExportColumn::make('result_url')
->state(function (Result $record) {
return $record->result_url;
Expand Down
19 changes: 19 additions & 0 deletions app/Filament/Resources/ResultResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\HtmlString;
use Illuminate\Support\Number as LaravelNumber;

class ResultResource extends Resource
{
Expand Down Expand Up @@ -83,6 +84,11 @@ public static function form(Form $form): Form
->formatStateUsing(function ($state) {
return number_format((float) $state, 0, '.', '').' ms';
}),
Forms\Components\TextInput::make('downloaded_bytes')
->label('Downloaded bytes')
->afterStateHydrated(function (TextInput $component, Result $record) {
$component->state(! blank($record->downloaded_bytes) ? LaravelNumber::fileSize(bytes: $record->downloaded_bytes, precision: 2) : '');
}),
Forms\Components\TextInput::make('data.upload.latency.jitter')
->label('Upload Jitter')
->formatStateUsing(function ($state) {
Expand All @@ -103,6 +109,11 @@ public static function form(Form $form): Form
->formatStateUsing(function ($state) {
return number_format((float) $state, 0, '.', '').' ms';
}),
Forms\Components\TextInput::make('uploaded_bytes')
->label('Uploaded bytes')
->afterStateHydrated(function (TextInput $component, Result $record) {
$component->state(! blank($record->downloaded_bytes) ? LaravelNumber::fileSize(bytes: $record->uploaded_bytes, precision: 2) : '');
}),
Forms\Components\TextInput::make('data.ping.jitter')
->label('Ping Jitter')
->formatStateUsing(function ($state) {
Expand Down Expand Up @@ -196,9 +207,17 @@ public static function table(Table $table): Table
Tables\Columns\TextColumn::make('download')
->getStateUsing(fn (Result $record): ?string => ! blank($record->download) ? Number::toBitRate(bits: $record->download_bits, precision: 2) : null)
->sortable(),
Tables\Columns\TextColumn::make('downloaded_bytes')
->toggleable()
->getStateUsing(fn (Result $record): ?string => ! blank($record->download) ? LaravelNumber::fileSize(bytes: $record->downloaded_bytes, precision: 2) : null)
->sortable(),
Tables\Columns\TextColumn::make('upload')
->getStateUsing(fn (Result $record): ?string => ! blank($record->upload) ? Number::toBitRate(bits: $record->upload_bits, precision: 2) : null)
->sortable(),
Tables\Columns\TextColumn::make('uploaded_bytes')
->toggleable()
->getStateUsing(fn (Result $record): ?string => ! blank($record->download) ? LaravelNumber::fileSize(bytes: $record->uploaded_bytes, precision: 2) : null)
->sortable(),
Tables\Columns\TextColumn::make('ping')
->toggleable()
->sortable()
Expand Down
2 changes: 2 additions & 0 deletions app/Http/Resources/V1/ResultResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ public function toArray(Request $request): array
'service' => $this->service,
'ping' => $this->ping,
'download' => $this->download,
'downloaded_bytes' => $this->downloaded_bytes,
'upload' => $this->upload,
'uploaded_bytes' => $this->uploaded_bytes,
'download_bits' => $this->when($this->download, fn (): int|float => Bitrate::bytesToBits($this->download)),
'upload_bits' => $this->when($this->upload, fn (): int|float => Bitrate::bytesToBits($this->upload)),
'download_bits_human' => $this->when($this->download, fn (): string => Bitrate::formatBits(Bitrate::bytesToBits($this->download)).'ps'),
Expand Down
2 changes: 2 additions & 0 deletions app/Jobs/Ookla/RunSpeedtestJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,9 @@ public function handle(): void
$this->result->update([
'ping' => Arr::get($output, 'ping.latency'),
'download' => Arr::get($output, 'download.bandwidth'),
'downloaded_bytes' => Arr::get($output, 'download.bytes'),
'upload' => Arr::get($output, 'upload.bandwidth'),
'uploaded_bytes' => Arr::get($output, 'upload.bytes'),
'data' => $output,
]);
}
Expand Down
2 changes: 2 additions & 0 deletions database/factories/ResultFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ public function definition(): array
'service' => ResultService::Faker,
'ping' => Arr::get($output, 'ping.latency'),
'download' => Arr::get($output, 'download.bandwidth'),
'downloaded_bytes' => Arr::get($output, 'download.bytes'),
'upload' => Arr::get($output, 'upload.bandwidth'),
'uploaded_bytes' => Arr::get($output, 'upload.bytes'),
'data' => $output,
'status' => ResultStatus::Completed,
'scheduled' => false,
Expand Down
27 changes: 27 additions & 0 deletions database/migrations/2025_04_16_000050_update_results_table.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('results', function (Blueprint $table) {
$table->unsignedBigInteger('downloaded_bytes')->nullable()->after('download');
$table->unsignedBigInteger('uploaded_bytes')->nullable()->after('upload');
});
}

/**
* Reverse the migrations.
*/
public function down(): void
{
//
}
};