From bb8b4c0e36afc05ff5b0cb3ac6465351a696b001 Mon Sep 17 00:00:00 2001 From: Frederic Guillot Date: Sun, 5 Jul 2015 16:07:21 -0400 Subject: Add task analytics --- app/Model/TaskAnalytic.php | 74 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 app/Model/TaskAnalytic.php (limited to 'app/Model/TaskAnalytic.php') diff --git a/app/Model/TaskAnalytic.php b/app/Model/TaskAnalytic.php new file mode 100644 index 00000000..41579c7d --- /dev/null +++ b/app/Model/TaskAnalytic.php @@ -0,0 +1,74 @@ +board->getColumnsList($task['project_id']); + $averages = $this->transition->getAverageTimeSpentByTask($task['id']); + + foreach ($columns as $column_id => $column_title) { + + $time_spent = 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; + } + + $result[] = array( + 'id' => $column_id, + 'title' => $column_title, + 'time_spent' => $time_spent, + ); + } + + return $result; + } +} -- cgit v1.2.3