From 819b2663ca402b48822cf9807ff399167ca078f4 Mon Sep 17 00:00:00 2001 From: Romain Quetiez Date: Fri, 7 Sep 2012 15:23:28 +0000 Subject: [PATCH] Stop watches - reset of deadlines + overrun SVN:trunk[2169] --- core/ormstopwatch.class.inc.php | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/core/ormstopwatch.class.inc.php b/core/ormstopwatch.class.inc.php index 23d85b6eb..ab514fac1 100644 --- a/core/ormstopwatch.class.inc.php +++ b/core/ormstopwatch.class.inc.php @@ -201,15 +201,11 @@ return false; $sThresholdDesc = $oAttDef->SecondsToDate($aThresholdData['deadline']); if ($aThresholdData['triggered']) { - if ($aThresholdData['overrun']) - { - $sThresholdDesc .= " TRIGGERED, Overrun:".(int) $aThresholdData['overrun']." seconds"; - } - else - { - // Still active, overrun unknown - $sThresholdDesc .= " TRIGGERED"; - } + $sThresholdDesc .= " TRIGGERED"; + } + if ($aThresholdData['overrun']) + { + $sThresholdDesc .= " Overrun:".(int) $aThresholdData['overrun']." sec."; } $aProperties[$iPercent.'%'] = $sThresholdDesc; } @@ -347,11 +343,14 @@ return false; // The threshold is in the future, reset $aThresholdData['passed'] = false; $aThresholdData['triggered'] = false; + $aThresholdData['overrun'] = null; } else { // The new threshold is in the past $aThresholdData['passed'] = true; + // Note: the overrun can be wrong, but the correct algorithm to compute + // the overrun of a deadline in the past requires that the ormStopWatch keeps track of all its history!!! } } @@ -376,7 +375,6 @@ return false; { if (!is_null($aThresholdData['deadline']) && (time() > $aThresholdData['deadline'])) { - $aThresholdData['passed'] = true; if ($aThresholdData['overrun'] > 0) { // Accumulate from last start @@ -388,6 +386,8 @@ return false; $iOverrun = $this->ComputeDuration($oObject, $oAttDef, $aThresholdData['deadline'], time()); $aThresholdData['overrun'] = $iOverrun; } + $aThresholdData['passed'] = true; + $aThresholdData['deadline'] = null; } }