Improve columns table in project settings
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -261,32 +261,6 @@ class ProjectModel extends Base
|
||||
->count();
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
*
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user