diff --git a/app/Models/Result.php b/app/Models/Result.php index 1bc7eeb37..c46bf57e6 100644 --- a/app/Models/Result.php +++ b/app/Models/Result.php @@ -59,6 +59,8 @@ class Result extends Model */ public function formatForInfluxDB2() { + $data = json_decode($this->data, true); + return [ 'id' => (int) $this->id, 'ping' => (float) $this->ping, @@ -66,14 +68,14 @@ public function formatForInfluxDB2() 'upload' => (int) $this->upload, 'download_bits' => (int) $this->download * 8, 'upload_bits' => (int) $this->upload * 8, - 'ping_jitter' => (float) $this->data['ping']['jitter'], - 'download_jitter' => (float) $this->data['download']['latency']['jitter'], - 'upload_jitter' => (float) $this->data['upload']['latency']['jitter'], + 'ping_jitter' => (float) $data['ping']['jitter'], + 'download_jitter' => (float) $data['download']['latency']['jitter'], + 'upload_jitter' => (float) $data['upload']['latency']['jitter'], 'server_id' => (int) $this->server_id, 'server_host' => $this->server_host, 'server_name' => $this->server_name, 'scheduled' => $this->scheduled, - 'packet_loss' => $this->data['packetLoss'], + 'packet_loss' => optional($data)['packetLoss'], // optional, because apparently the cli doesn't always have this metric ]; } }