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 | |
parent | 85b3e4a617d89fbcc1b21e4d8376bf663b5ff78a (diff) |
Added 'model:subtask:count:query' to SubtaskModel.
-rw-r--r-- | app/Model/SubtaskModel.php | 15 | ||||
-rw-r--r-- | doc/en_US/plugin-hooks.markdown | 1 |
2 files changed, 13 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(); } /** diff --git a/doc/en_US/plugin-hooks.markdown b/doc/en_US/plugin-hooks.markdown index 54b9f689..09b8936b 100644 --- a/doc/en_US/plugin-hooks.markdown +++ b/doc/en_US/plugin-hooks.markdown @@ -144,6 +144,7 @@ List of reference hooks: | `model:color:get-list` | Alter default_colors values | | `model:subtask:modification:prepare` | Alter form values before to save a subtask | | `model:subtask:creation:prepare` | Alter form values before to edit a subtask | +| `model:subtask:count:query` | Alter database query for subtask count | Template Hooks |