Add download and upload bytes (#2301)

Co-authored-by: Alex Justesen <1144087+alexjustesen@users.noreply.github.com>
This commit is contained in:
Alex Justesen
2025-07-31 19:27:04 -04:00
committed by GitHub
parent f4be64a8be
commit 1fec5d05a5
5 changed files with 40 additions and 2 deletions
+2 -2
View File
@@ -50,8 +50,8 @@ class BuildPointData
->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('downloaded_bytes', Number::castToType(Arr::get($result->data, 'downloaded_bytes'), 'float'))
->addField('uploaded_bytes', Number::castToType(Arr::get($result->data, 'uploaded_bytes'), 'float'))
->addField('downloaded_bytes', Number::castToType($result->data, 'download_bytes', 'float'))
->addField('uploaded_bytes', Number::castToType($result->data, 'upload_bytes', 'float'))
->addField('packet_loss', Number::castToType(Arr::get($result->data, 'packetLoss'), 'float'))
->addField('log_message', Arr::get($result->data, 'message'));
+5
View File
@@ -5,6 +5,7 @@ namespace App\Http\Resources\V1;
use App\Helpers\Bitrate;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;
use Illuminate\Support\Number;
class ResultResource extends JsonResource
{
@@ -25,6 +26,10 @@ class ResultResource extends JsonResource
'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'),
'upload_bits_human' => $this->when($this->upload, fn (): string => Bitrate::formatBits(Bitrate::bytesToBits($this->upload)).'ps'),
'download_bytes' => $this->download_bytes,
'upload_bytes' => $this->upload_bytes,
'download_bytes_human' => $this->when($this->download_bytes, fn (): string => Number::fileSize($this->download_bytes)),
'upload_bytes_human' => $this->when($this->upload_bytes, fn (): string => Number::fileSize($this->upload_bytes)),
'benchmarks' => $this->benchmarks,
'healthy' => $this->healthy,
'status' => $this->status,
+2
View File
@@ -90,6 +90,8 @@ class RunSpeedtestJob implements ShouldQueue
'ping' => Arr::get($output, 'ping.latency'),
'download' => Arr::get($output, 'download.bandwidth'),
'upload' => Arr::get($output, 'upload.bandwidth'),
'download_bytes' => Arr::get($output, 'download.bytes'),
'upload_bytes' => Arr::get($output, 'upload.bytes'),
'data' => $output,
]);
}
+2
View File
@@ -45,6 +45,8 @@ class ResultFactory extends Factory
'ping' => Arr::get($output, 'ping.latency'),
'download' => Arr::get($output, 'download.bandwidth'),
'upload' => Arr::get($output, 'upload.bandwidth'),
'download_bytes' => Arr::get($output, 'download.bytes'),
'upload_bytes' => Arr::get($output, 'upload.bytes'),
'data' => $output,
'status' => ResultStatus::Completed,
'scheduled' => false,
@@ -0,0 +1,29 @@
<?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->after('upload', function (Blueprint $table) {
$table->unsignedBigInteger('download_bytes')->nullable();
$table->unsignedBigInteger('upload_bytes')->nullable();
});
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
//
}
};