Skip to content

Commit 73ba1c1

Browse files
authored
made additional metrics nullable in case they're not available (alexjustesen#168)
1 parent e6eb19f commit 73ba1c1

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

app/Models/Result.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,14 +68,14 @@ public function formatForInfluxDB2()
6868
'upload' => (int) $this->upload,
6969
'download_bits' => (int) $this->download * 8,
7070
'upload_bits' => (int) $this->upload * 8,
71-
'ping_jitter' => (float) $data['ping']['jitter'],
72-
'download_jitter' => (float) $data['download']['latency']['jitter'],
73-
'upload_jitter' => (float) $data['upload']['latency']['jitter'],
71+
'ping_jitter' => (float) $data['ping']['jitter'] ?? null,
72+
'download_jitter' => (float) $data['download']['latency']['jitter'] ?? null,
73+
'upload_jitter' => (float) $data['upload']['latency']['jitter'] ?? null,
7474
'server_id' => (int) $this->server_id,
7575
'server_host' => $this->server_host,
7676
'server_name' => $this->server_name,
7777
'scheduled' => $this->scheduled,
78-
'packet_loss' => optional($data)['packetLoss'], // optional, because apparently the cli doesn't always have this metric
78+
'packet_loss' => (float) $data['packetLoss'] ?? null, // optional, because apparently the cli doesn't always have this metric
7979
];
8080
}
8181
}

0 commit comments

Comments
 (0)