dashboard: fix datastore full estimate for not changing usage

If the usage of a datastore did not change, we did not
return an estimate. The ui interpreted this as 'not enough data', but
it should actually be 'never'.

Fixing this by always setting the estimate first to 0 and overwriting
if we successfully calculated one, and checking for 'undefined' in the ui.

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
This commit is contained in:
Dominik Csapak 2021-03-02 14:38:49 +01:00 committed by Dietmar Maurer
parent ac4a1fb35c
commit 347cde827b
2 changed files with 2 additions and 3 deletions

View File

@ -160,12 +160,11 @@ pub fn datastore_status(
// we skip the calculation for datastores with not enough data // we skip the calculation for datastores with not enough data
if usage_list.len() >= 7 { if usage_list.len() >= 7 {
entry["estimated-full-date"] = Value::from(0);
if let Some((a,b)) = linear_regression(&time_list, &usage_list) { if let Some((a,b)) = linear_regression(&time_list, &usage_list) {
if b != 0.0 { if b != 0.0 {
let estimate = (1.0 - a) / b; let estimate = (1.0 - a) / b;
entry["estimated-full-date"] = Value::from(estimate.floor() as u64); entry["estimated-full-date"] = Value::from(estimate.floor() as u64);
} else {
entry["estimated-full-date"] = Value::from(0);
} }
} }
} }

View File

@ -277,7 +277,7 @@ Ext.define('PBS.Utils', {
}, },
render_estimate: function(value) { render_estimate: function(value) {
if (!value) { if (value === undefined) {
return gettext('Not enough data'); return gettext('Not enough data');
} }