From 4460851615d16b1ad0047b3d21389396d8ce5234 Mon Sep 17 00:00:00 2001 From: Frederic Guillot Date: Tue, 7 Apr 2015 21:06:15 -0400 Subject: Display the sum of task complexity in the column --- app/Model/Board.php | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'app/Model') diff --git a/app/Model/Board.php b/app/Model/Board.php index 8a344f7f..711f3dd9 100644 --- a/app/Model/Board.php +++ b/app/Model/Board.php @@ -225,6 +225,7 @@ class Board extends Base for ($j = 0; $j < $nb_columns; $j++) { $swimlanes[$i]['columns'][$j]['tasks'] = $this->taskFinder->getTasksByColumnAndSwimlane($project_id, $columns[$j]['id'], $swimlanes[$i]['id']); $swimlanes[$i]['columns'][$j]['nb_tasks'] = count($swimlanes[$i]['columns'][$j]['tasks']); + $swimlanes[$i]['columns'][$j]['score'] = $this->getColumnSum($swimlanes[$i]['columns'][$j]['tasks'], 'score'); $swimlanes[$i]['nb_tasks'] += $swimlanes[$i]['columns'][$j]['nb_tasks']; } } @@ -232,6 +233,25 @@ class Board extends Base return $swimlanes; } + /** + * Calculate the sum of the defined field for a list of tasks + * + * @access public + * @param array $tasks + * @param string $field + * @return integer + */ + public function getColumnSum(array &$tasks, $field) + { + $sum = 0; + + foreach ($tasks as $task) { + $sum += $task['score']; + } + + return $sum; + } + /** * Get the total of tasks per column * -- cgit v1.2.3