From 8768a4e3699c5b9235d8c834ad7689ae66ef36aa Mon Sep 17 00:00:00 2001 From: Frederic Guillot Date: Tue, 22 Mar 2016 20:44:15 -0400 Subject: Fixes cycle time calculation when the start date is defined in the future --- app/Analytic/AverageLeadCycleTimeAnalytic.php | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'app/Analytic') 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; } /** -- cgit v1.2.3