diff options
author | CoRex <dev@corex.dk> | 2017-12-07 20:03:14 +0100 |
---|---|---|
committer | fguillot <fred@kanboard.net> | 2017-12-07 16:49:18 -0800 |
commit | 7572edf59aae68c33a216534438acb407cc4325d (patch) | |
tree | 4e929c7568c018f592e278b3bab5b9c523da06e8 /app/Model | |
parent | 85b3e4a617d89fbcc1b21e4d8376bf663b5ff78a (diff) |
Added 'model:subtask:count:query' to SubtaskModel.
Diffstat (limited to 'app/Model')
-rw-r--r-- | app/Model/SubtaskModel.php | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/app/Model/SubtaskModel.php b/app/Model/SubtaskModel.php index 1e652ae2..626ccbef 100644 --- a/app/Model/SubtaskModel.php +++ b/app/Model/SubtaskModel.php @@ -88,13 +88,22 @@ class SubtaskModel extends Base ->asc(self::TABLE.'.position'); } + /** + * Count by assignee and task status. + * + * @param integer $userId + * @return integer + */ public function countByAssigneeAndTaskStatus($userId) { - return $this->db->table(self::TABLE) + $query = $this->db->table(self::TABLE) ->eq('user_id', $userId) ->eq(TaskModel::TABLE.'.is_active', TaskModel::STATUS_OPEN) - ->join(Taskmodel::TABLE, 'id', 'task_id') - ->count(); + ->join(Taskmodel::TABLE, 'id', 'task_id'); + + $this->hook->reference('model:subtask:count:query', $query); + + return $query->count(); } /** |