diff options
author | Frederic Guillot <fred@kanboard.net> | 2016-03-22 20:44:15 -0400 |
---|---|---|
committer | Frederic Guillot <fred@kanboard.net> | 2016-03-22 20:44:15 -0400 |
commit | 8768a4e3699c5b9235d8c834ad7689ae66ef36aa (patch) | |
tree | 6be77f7213fd6e3f865c3d71e4f3809cf1cac1c4 /app/Analytic | |
parent | 585f73433373d8e2912c60f4ed0efab827484232 (diff) |
Fixes cycle time calculation when the start date is defined in the future
Diffstat (limited to 'app/Analytic')
-rw-r--r-- | app/Analytic/AverageLeadCycleTimeAnalytic.php | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/app/Analytic/AverageLeadCycleTimeAnalytic.php b/app/Analytic/AverageLeadCycleTimeAnalytic.php index 5a7a3c0f..62c83559 100644 --- a/app/Analytic/AverageLeadCycleTimeAnalytic.php +++ b/app/Analytic/AverageLeadCycleTimeAnalytic.php @@ -85,14 +85,15 @@ class AverageLeadCycleTimeAnalytic extends Base */ private function calculateCycleTime(array &$task) { - if (empty($task['date_started'])) { - return 0; - } + $end = (int) $task['date_completed'] ?: time(); + $start = (int) $task['date_started']; - $end = $task['date_completed'] ?: time(); - $start = $task['date_started']; + // Start date can be in the future when defined with the Gantt chart + if ($start > 0 && $end > $start) { + return $end - $start; + } - return $end - $start; + return 0; } /** |