Fix metrics error when data is less than selected date
Related to #4309 Fix the 'sql: Scan error on column index 5, name "usedPercent": converting NULL to float64 is unsupported' error on the metrics page. * Update the `getMemoryMetrics` method in `app/Models/Server.php` to handle NULL values for the "usedPercent" field by setting them to 0.0. * Add a check for NULL values in the `getMemoryMetrics` method before converting to float64.
This commit is contained in:
parent
13f9b153e7
commit
f45411f3d6
1 changed files with 2 additions and 1 deletions
|
|
@ -611,7 +611,8 @@ public function getMemoryMetrics(int $mins = 5)
|
|||
}
|
||||
$memory = json_decode($memory, true);
|
||||
$parsedCollection = collect($memory)->map(function ($metric) {
|
||||
return [(int) $metric['time'], (float) $metric['usedPercent']];
|
||||
$usedPercent = $metric['usedPercent'] ?? 0.0;
|
||||
return [(int) $metric['time'], (float) $usedPercent];
|
||||
});
|
||||
|
||||
return $parsedCollection->toArray();
|
||||
|
|
|
|||
Loading…
Reference in a new issue