diff options
Diffstat (limited to 'app/Analytic/AverageLeadCycleTimeAnalytic.php')
-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; } /** |