From d7b0cfbbe57fae9afbf9637afa7e54d3bf708747 Mon Sep 17 00:00:00 2001 From: Frederic Guillot Date: Sat, 8 Apr 2017 13:58:25 -0400 Subject: Improve dashboard --- app/Model/ProjectModel.php | 21 +++++++++++++++++++++ app/Model/SubtaskModel.php | 9 +++++++++ 2 files changed, 30 insertions(+) (limited to 'app/Model') diff --git a/app/Model/ProjectModel.php b/app/Model/ProjectModel.php index cabfee8a..7f489c75 100644 --- a/app/Model/ProjectModel.php +++ b/app/Model/ProjectModel.php @@ -303,6 +303,27 @@ class ProjectModel extends Base return $projects; } + /** + * Get project summary for a list of project + * + * @access public + * @param array $project_ids List of project id + * @return \PicoDb\Table + */ + public function getQueryColumnStats(array $project_ids) + { + if (empty($project_ids)) { + return $this->db->table(ProjectModel::TABLE)->eq(ProjectModel::TABLE.'.id', 0); + } + + return $this->db + ->table(ProjectModel::TABLE) + ->columns(self::TABLE.'.*', UserModel::TABLE.'.username AS owner_username', UserModel::TABLE.'.name AS owner_name') + ->join(UserModel::TABLE, 'id', 'owner_id') + ->in(self::TABLE.'.id', $project_ids) + ->callback(array($this, 'applyColumnStats')); + } + /** * Get query for list of project without column statistics * diff --git a/app/Model/SubtaskModel.php b/app/Model/SubtaskModel.php index 40cb517d..1e652ae2 100644 --- a/app/Model/SubtaskModel.php +++ b/app/Model/SubtaskModel.php @@ -88,6 +88,15 @@ class SubtaskModel extends Base ->asc(self::TABLE.'.position'); } + public function countByAssigneeAndTaskStatus($userId) + { + return $this->db->table(self::TABLE) + ->eq('user_id', $userId) + ->eq(TaskModel::TABLE.'.is_active', TaskModel::STATUS_OPEN) + ->join(Taskmodel::TABLE, 'id', 'task_id') + ->count(); + } + /** * Get all subtasks for a given task * -- cgit v1.2.3