From 38dcc71457b38789c91ba3e4754dd14a4ad142b6 Mon Sep 17 00:00:00 2001 From: Greg Bowler Date: Tue, 13 Nov 2018 20:12:32 +0000 Subject: [PATCH] Differentiate between cumulative and rolling counters --- sync-remote-cfg.php | 2 +- www/logbox/output.php | 29 ++++++++++++++++--------- www/logbox/settings.php | 48 ++++++++++++++++++++++++++++++----------- 3 files changed, 56 insertions(+), 23 deletions(-) diff --git a/sync-remote-cfg.php b/sync-remote-cfg.php index f5a1b3c..1beb28c 100644 --- a/sync-remote-cfg.php +++ b/sync-remote-cfg.php @@ -43,7 +43,7 @@ if($sourceNeedsUpdate) { echo "Updating source..." . PHP_EOL; - rename($cfgPath, "$cfgPath.old"); + copy($cfgPath, $cfgPath . ".old"); file_put_contents($cfgPath, $json->serialized); } diff --git a/www/logbox/output.php b/www/logbox/output.php index 2f827a2..f89290d 100644 --- a/www/logbox/output.php +++ b/www/logbox/output.php @@ -30,21 +30,30 @@ $lowerKey = strtolower($key); $name = $cfg["{$lowerKey}_name"]; - if(empty($name)) { - continue; - } + if(!empty($name)) { + $formula = $cfg["{$lowerKey}_formula"] ?: "x"; + + $formula = str_replace("x", $value, $formula); + $calcValue = exec("echo \"$formula\" | bc"); - $mins = $cfg["{$lowerKey}_mins"] ?: 0; - if($mins > 0) { - $value = getValueOverTime($key, $mins); + echo "$name\t$calcValue" . PHP_EOL; } - $formula = $cfg["{$lowerKey}_formula"] ?: "x"; + $mins_name = $cfg["{$lowerKey}_mins_name"]; + if(!empty($mins_name)) { + $value = 0; - $formula = str_replace("x", $value, $formula); - $calcValue = exec("echo \"$formula\" | bc"); + $mins = $cfg["{$lowerKey}_mins"] ?: 0; + if($mins > 0) { + $value = getValueOverTime($key, $mins); + } - echo "$name\t$calcValue" . PHP_EOL; + $formula = $cfg["{$lowerKey}_mins_formula"] ?: "x"; + $formula = str_replace("x", $value, $formula); + $calcValue = exec("echo \"$formula\" | bc"); + + echo "$mins_name\t$calcValue" . PHP_EOL; + } } echo PHP_EOL . ""; diff --git a/www/logbox/settings.php b/www/logbox/settings.php index f96a1b1..f048dbd 100644 --- a/www/logbox/settings.php +++ b/www/logbox/settings.php @@ -51,14 +51,22 @@ Name - + + +

C2

@@ -66,14 +74,22 @@ Name - + + +

C3

@@ -81,14 +97,22 @@ Name - + + +