diff options
author | Frederic Guillot <fred@kanboard.net> | 2015-04-07 21:06:15 -0400 |
---|---|---|
committer | Frederic Guillot <fred@kanboard.net> | 2015-04-07 21:06:15 -0400 |
commit | 4460851615d16b1ad0047b3d21389396d8ce5234 (patch) | |
tree | bca11098edcb20f1df379767a236e442932ab391 /app/Model | |
parent | 7d1c84699ac12f91bf711ded5c93b57a644fabbf (diff) |
Display the sum of task complexity in the column
Diffstat (limited to 'app/Model')
-rw-r--r-- | app/Model/Board.php | 20 |
1 files changed, 20 insertions, 0 deletions
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']; } } @@ -233,6 +234,25 @@ class Board extends Base } /** + * 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 * * @access public |