summaryrefslogtreecommitdiff
path: root/app/Model/TaskAnalytic.php
diff options
context:
space:
mode:
authorFrederic Guillot <fred@kanboard.net>2015-07-05 21:22:31 -0400
committerFrederic Guillot <fred@kanboard.net>2015-07-05 21:22:31 -0400
commit663a1c20e6ba0fbf65afcb43f0f48d34f21dcb53 (patch)
tree86b86c9c83770456242fb65779aac68dc497fb54 /app/Model/TaskAnalytic.php
parentbb8b4c0e36afc05ff5b0cb3ac6465351a696b001 (diff)
Add new analytic page: Average time spent into each column
Diffstat (limited to 'app/Model/TaskAnalytic.php')
-rw-r--r--app/Model/TaskAnalytic.php13
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(