diff options
author | Frederic Guillot <fred@kanboard.net> | 2015-07-05 21:22:31 -0400 |
---|---|---|
committer | Frederic Guillot <fred@kanboard.net> | 2015-07-05 21:22:31 -0400 |
commit | 663a1c20e6ba0fbf65afcb43f0f48d34f21dcb53 (patch) | |
tree | 86b86c9c83770456242fb65779aac68dc497fb54 /app/Model/TaskAnalytic.php | |
parent | bb8b4c0e36afc05ff5b0cb3ac6465351a696b001 (diff) |
Add new analytic page: Average time spent into each column
Diffstat (limited to 'app/Model/TaskAnalytic.php')
-rw-r--r-- | app/Model/TaskAnalytic.php | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/app/Model/TaskAnalytic.php b/app/Model/TaskAnalytic.php index 41579c7d..33a645c1 100644 --- a/app/Model/TaskAnalytic.php +++ b/app/Model/TaskAnalytic.php @@ -45,21 +45,18 @@ class TaskAnalytic extends Base * @param array $task * @return array */ - public function getAverageTimeByColumn(array $task) + public function getTimeSpentByColumn(array $task) { $result = array(); $columns = $this->board->getColumnsList($task['project_id']); - $averages = $this->transition->getAverageTimeSpentByTask($task['id']); + $sums = $this->transition->getTimeSpentByTask($task['id']); foreach ($columns as $column_id => $column_title) { - $time_spent = 0; + $time_spent = isset($sums[$column_id]) ? $sums[$column_id] : 0; - if (empty($averages) && $task['column_id'] == $column_id) { - $time_spent = time() - $task['date_creation']; - } - else { - $time_spent = isset($averages[$column_id]) ? $averages[$column_id] : 0; + if ($task['column_id'] == $column_id) { + $time_spent += ($task['date_completed'] ?: time()) - $task['date_moved']; } $result[] = array( |