mirror of
https://github.com/lucaspalomodevelop/core.git
synced 2026-03-14 16:44:39 +00:00
SystemHealth, some small style fixes and "non-numeric value encountered" when inverting graph, see https://github.com/opnsense/core/issues/2228
This commit is contained in:
parent
912dd0dda1
commit
048f3d0b4f
@ -89,13 +89,9 @@ class SystemhealthController extends ApiControllerBase
|
||||
foreach ($data->database->row as $item => $row) {
|
||||
foreach ($row as $rowKey => $rowVal) {
|
||||
if (trim($rowVal) != "NaN") {
|
||||
$containsValues = true;
|
||||
break 2;
|
||||
}
|
||||
}
|
||||
if ($containsValues == true) {
|
||||
break;
|
||||
}
|
||||
$rowNumber++;
|
||||
}
|
||||
|
||||
return $rowNumber;
|
||||
@ -126,9 +122,7 @@ class SystemhealthController extends ApiControllerBase
|
||||
*/
|
||||
private function getSelection($rra_info, $from_timestamp, $to_timestamp, $max_values)
|
||||
{
|
||||
$full_range = false;
|
||||
if ($from_timestamp == 0 && $to_timestamp == 0) {
|
||||
$full_range = true;
|
||||
$from_timestamp = $this->getMaxRange($rra_info)["oldest_timestamp"];
|
||||
$to_timestamp = $this->getMaxRange($rra_info)["newest_timestamp"];
|
||||
}
|
||||
@ -143,22 +137,16 @@ class SystemhealthController extends ApiControllerBase
|
||||
$rowCount = ($to_timestamp - $from_timestamp) / $value['full_step'] + 1;
|
||||
|
||||
// factor to be used to compress the data.
|
||||
// example if 2 then 2 values will be used to calculate one data point.
|
||||
$condense_factor = round($rowCount / $max_values);
|
||||
// example if 2 then 2 values will be used to calculate one data point, minimum 1 (don't condense).
|
||||
$condense_factor = round($rowCount / $max_values) < 1 ? 1 : round($rowCount / $max_values);
|
||||
|
||||
if ($condense_factor == 0) { // if rounded to 0 we will not condense the data
|
||||
$condense_factor = 1; // and thus return the full set of data points
|
||||
}
|
||||
// actual number of rows after compressing/condensing the dataSet
|
||||
$condensed_rowCount = (int)($rowCount / $condense_factor);
|
||||
|
||||
// count the number if rra's (sets), deduct 1 as we need the counter to start at 0
|
||||
$last_rra_key = count($rra_info) - 1;
|
||||
|
||||
// dynamic (condensed) values for full overview to detail level
|
||||
$overview = round($rra_info[$last_rra_key]["available_rows"] / (int)$max_values);
|
||||
|
||||
if ($full_range == false) { // JSC WIP removed: && count($rra_info)==1 // add detail when selected
|
||||
if ($from_timestamp == 0 && $to_timestamp == 0) { // add detail when selected
|
||||
array_push($archives, [
|
||||
"key" => $key,
|
||||
"condensed_rowCount" => $condensed_rowCount,
|
||||
@ -183,6 +171,9 @@ class SystemhealthController extends ApiControllerBase
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// dynamic (condensed) values for full overview to detail level
|
||||
$overview = round($rra_info[$last_rra_key]["available_rows"] / (int)$max_values);
|
||||
if ($overview != 0) {
|
||||
$condensed_rowCount = (int)($rra_info[$last_rra_key]["available_rows"] / $overview);
|
||||
} else {
|
||||
@ -199,7 +190,9 @@ class SystemhealthController extends ApiControllerBase
|
||||
}
|
||||
}
|
||||
|
||||
return (["from" => $from_timestamp, "to" => $to_timestamp, "full_range" => $full_range, "data" => $archives]);
|
||||
return (["from" => $from_timestamp, "to" => $to_timestamp,
|
||||
"full_range" => ($from_timestamp == 0 && $to_timestamp == 0),
|
||||
"data" => $archives]);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -275,13 +268,12 @@ class SystemhealthController extends ApiControllerBase
|
||||
} else {
|
||||
$nan = false; // Not a NaN value, so add to list
|
||||
}
|
||||
if ($applyInverse == true) {
|
||||
$check_value = $key / 2; // every odd row gets data inversed (* -1)
|
||||
if ($check_value != (int)$check_value) {
|
||||
if ($value != "NaN" && $applyInverse) {
|
||||
if ($key % 2 != 0) {
|
||||
$value = $value * -1;
|
||||
}
|
||||
}
|
||||
if ($nan == false) {
|
||||
if (!$nan) {
|
||||
if ($from_timestamp == 0 || $timestamp < $from_timestamp) {
|
||||
$from_timestamp = $timestamp; // Actual from_timestamp after condensing and cleaning data
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user