-
-
Notifications
You must be signed in to change notification settings - Fork 204
Description
Describe the bug
The output of a speedtest is being store in results.data in the incorrect format. The field contains escaping characters \ and new lines \n which breaks Laravel's model casting from working correctly.
To Reproduce
Steps to reproduce the behavior:
- Go to the dashboard
- Click on "Queue Speedtest" and wait for it to run
- Open a database IDE and browse the table
results - See incorrectly formatted json
Expected behavior
Modify app/Jobs/ExecSpeedtest.php to correctly store the results received by the speedtest-cli.
Result::create([
//...
'data' => $output, // <- change this
'data' => $results, // <- to this and let Laravel convert the array automatically.
]);Screenshots
The last row of this screenshot has the correct data format when using the decoded $output value from $results.

Additional Context
This has been the root cause of a lot of the other issues and the model attribute casting not working. The issue keeps cropping up when passing data to InfluxDB.
Things that will break
- InfluxDb integration
- Dashboard charts
- Results table
- Legacy APIs
- tbd...
Databases to test
- sqlite
- mysql/mariadb
- postgresql
Steps to fix the issue
Option 1 - iterate through each record and re-encode it.
DB::table('results')->chunkById(100, function ($result) {
foreach ($results as $result) {
$data = json_decode($result->data);
DB::table('results')
->where('id', $result->id)
->update(['data' => $data]);
}
});Option x - tbd...