From 90761f0f62bef2bc1f7588acc2c674983edbf519 Mon Sep 17 00:00:00 2001 From: Thomas Lamprecht Date: Fri, 21 May 2021 10:29:14 +0200 Subject: [PATCH] api: datastore status: code cleanup, reduce indentation level Signed-off-by: Thomas Lamprecht --- src/api2/status.rs | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/api2/status.rs b/src/api2/status.rs index 11b46154..a6668c85 100644 --- a/src/api2/status.rs +++ b/src/api2/status.rs @@ -160,13 +160,10 @@ pub fn datastore_status( // we skip the calculation for datastores with not enough data if usage_list.len() >= 7 { - entry["estimated-full-date"] = Value::from(0); - if let Some((a,b)) = linear_regression(&time_list, &usage_list) { - if b != 0.0 { - let estimate = (1.0 - a) / b; - entry["estimated-full-date"] = Value::from(estimate.floor() as u64); - } - } + entry["estimated-full-date"] = match linear_regression(&time_list, &usage_list) { + Some((a, b)) if b != 0.0 => Value::from(((1.0 - a) / b).floor() as u64), + _ => Value::from(0), + }; } }