diff options
Diffstat (limited to 'app/Model')
-rw-r--r-- | app/Model/BoardModel.php | 20 | ||||
-rw-r--r-- | app/Model/ProjectModel.php | 34 |
2 files changed, 3 insertions, 51 deletions
diff --git a/app/Model/BoardModel.php b/app/Model/BoardModel.php index 4d559936..d80fb28f 100644 --- a/app/Model/BoardModel.php +++ b/app/Model/BoardModel.php @@ -92,24 +92,4 @@ class BoardModel extends Base return $this->boardModel->create($project_to, $columns); } - - /** - * Get the total of tasks per column - * - * @access public - * @param integer $project_id - * @param boolean $prepend Prepend default value - * @return array - */ - public function getColumnStats($project_id, $prepend = false) - { - $listing = $this->db - ->hashtable(TaskModel::TABLE) - ->eq('project_id', $project_id) - ->eq('is_active', 1) - ->groupBy('column_id') - ->getAll('column_id', 'COUNT(*) AS total'); - - return $prepend ? array(-1 => t('All columns')) + $listing : $listing; - } } diff --git a/app/Model/ProjectModel.php b/app/Model/ProjectModel.php index 080217cb..7f9cfb9b 100644 --- a/app/Model/ProjectModel.php +++ b/app/Model/ProjectModel.php @@ -262,32 +262,6 @@ class ProjectModel extends Base } /** - * Gather some task metrics for a given project - * - * @access public - * @param integer $project_id Project id - * @return array - */ - public function getTaskStats($project_id) - { - $stats = array(); - $stats['nb_active_tasks'] = 0; - $columns = $this->columnModel->getAll($project_id); - $column_stats = $this->boardModel->getColumnStats($project_id); - - foreach ($columns as &$column) { - $column['nb_active_tasks'] = isset($column_stats[$column['id']]) ? $column_stats[$column['id']] : 0; - $stats['nb_active_tasks'] += $column['nb_active_tasks']; - } - - $stats['columns'] = $columns; - $stats['nb_tasks'] = $this->taskFinderModel->countByProjectId($project_id); - $stats['nb_inactive_tasks'] = $stats['nb_tasks'] - $stats['nb_active_tasks']; - - return $stats; - } - - /** * Get stats for each column of a project * * @access public @@ -296,13 +270,11 @@ class ProjectModel extends Base */ public function getColumnStats(array &$project) { - $project['columns'] = $this->columnModel->getAll($project['id']); + $project['columns'] = $this->columnModel->getAllWithTasksCount($project['id']); $project['nb_active_tasks'] = 0; - $stats = $this->boardModel->getColumnStats($project['id']); - foreach ($project['columns'] as &$column) { - $column['nb_tasks'] = isset($stats[$column['id']]) ? $stats[$column['id']] : 0; - $project['nb_active_tasks'] += $column['nb_tasks']; + foreach ($project['columns'] as $column) { + $project['nb_active_tasks'] += $column['nb_open_tasks']; } return $project; |