diff options
Diffstat (limited to 'app/Model')
-rw-r--r-- | app/Model/Acl.php | 1 | ||||
-rw-r--r-- | app/Model/ProjectAnalytic.php | 43 |
2 files changed, 44 insertions, 0 deletions
diff --git a/app/Model/Acl.php b/app/Model/Acl.php index 9a6866d3..52957130 100644 --- a/app/Model/Acl.php +++ b/app/Model/Acl.php @@ -41,6 +41,7 @@ class Acl extends Base 'task' => array('show', 'create', 'save', 'edit', 'update', 'close', 'open', 'duplicate', 'remove', 'description', 'move', 'copy', 'time'), 'category' => array('index', 'save', 'edit', 'update', 'confirm', 'remove'), 'action' => array('index', 'event', 'params', 'create', 'confirm', 'remove'), + 'analytic' => array('repartition'), ); /** diff --git a/app/Model/ProjectAnalytic.php b/app/Model/ProjectAnalytic.php new file mode 100644 index 00000000..ccd2c4c9 --- /dev/null +++ b/app/Model/ProjectAnalytic.php @@ -0,0 +1,43 @@ +<?php + +namespace Model; + +/** + * Project analytic model + * + * @package model + * @author Frederic Guillot + */ +class ProjectAnalytic extends Base +{ + /** + * Get task repartition + * + * @access public + * @param integer $project_id Project id + * @return array + */ + public function getTaskRepartition($project_id) + { + $metrics = array(); + $total = 0; + $columns = $this->board->getColumns($project_id); + + foreach ($columns as $column) { + + $nb_tasks = $this->taskFinder->countByColumnId($project_id, $column['id']); + $total += $nb_tasks; + + $metrics[] = array( + 'column_title' => $column['title'], + 'nb_tasks' => $nb_tasks, + ); + } + + foreach ($metrics as &$metric) { + $metric['percentage'] = round(($metric['nb_tasks'] * 100) / $total, 2); + } + + return $metrics; + } +} |