committed by
Frédéric Guillot
parent
4d07628054
commit
51b3d811e1
@@ -55,13 +55,7 @@ class TaskCommentFilter extends BaseFilter implements FilterInterface
|
|||||||
*/
|
*/
|
||||||
public function apply()
|
public function apply()
|
||||||
{
|
{
|
||||||
$task_ids = $this->getTaskIdsWithGivenComment();
|
$this->query->inSubquery(TaskModel::TABLE.'.id', $this->getSubQuery());
|
||||||
|
|
||||||
if (empty($task_ids)) {
|
|
||||||
$task_ids = array(-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->query->in(TaskModel::TABLE.'.id', $task_ids);
|
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
@@ -72,11 +66,11 @@ class TaskCommentFilter extends BaseFilter implements FilterInterface
|
|||||||
* @access public
|
* @access public
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
protected function getTaskIdsWithGivenComment()
|
protected function getSubQuery()
|
||||||
{
|
{
|
||||||
return $this->db
|
return $this->db
|
||||||
->table(CommentModel::TABLE)
|
->table(CommentModel::TABLE)
|
||||||
->ilike(CommentModel::TABLE.'.comment', '%'.$this->value.'%')
|
->columns(CommentModel::TABLE.'.task_id')
|
||||||
->findAllByColumn(CommentModel::TABLE.'.task_id');
|
->ilike(CommentModel::TABLE.'.comment', '%'.$this->value.'%');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -57,13 +57,7 @@ class TaskLinkFilter extends BaseFilter implements FilterInterface
|
|||||||
*/
|
*/
|
||||||
public function apply()
|
public function apply()
|
||||||
{
|
{
|
||||||
$task_ids = $this->getSubQuery()->findAllByColumn('task_id');
|
$this->query->inSubquery(TaskModel::TABLE.'.id', $this->getSubQuery());
|
||||||
|
|
||||||
if (! empty($task_ids)) {
|
|
||||||
$this->query->in(TaskModel::TABLE.'.id', $task_ids);
|
|
||||||
} else {
|
|
||||||
$this->query->eq(TaskModel::TABLE.'.id', 0); // No match
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -76,8 +70,7 @@ class TaskLinkFilter extends BaseFilter implements FilterInterface
|
|||||||
{
|
{
|
||||||
return $this->db->table(TaskLinkModel::TABLE)
|
return $this->db->table(TaskLinkModel::TABLE)
|
||||||
->columns(
|
->columns(
|
||||||
TaskLinkModel::TABLE.'.task_id',
|
TaskLinkModel::TABLE.'.task_id'
|
||||||
LinkModel::TABLE.'.label'
|
|
||||||
)
|
)
|
||||||
->join(LinkModel::TABLE, 'id', 'link_id', TaskLinkModel::TABLE)
|
->join(LinkModel::TABLE, 'id', 'link_id', TaskLinkModel::TABLE)
|
||||||
->ilike(LinkModel::TABLE.'.label', $this->value);
|
->ilike(LinkModel::TABLE.'.label', $this->value);
|
||||||
|
|||||||
@@ -78,13 +78,7 @@ class TaskSubtaskAssigneeFilter extends BaseFilter implements FilterInterface
|
|||||||
*/
|
*/
|
||||||
public function apply()
|
public function apply()
|
||||||
{
|
{
|
||||||
$task_ids = $this->getSubQuery()->findAllByColumn('task_id');
|
$this->query->inSubquery(TaskModel::TABLE.'.id', $this->getSubQuery());
|
||||||
|
|
||||||
if (! empty($task_ids)) {
|
|
||||||
$this->query->in(TaskModel::TABLE.'.id', $task_ids);
|
|
||||||
} else {
|
|
||||||
$this->query->eq(TaskModel::TABLE.'.id', 0); // No match
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -96,12 +90,7 @@ class TaskSubtaskAssigneeFilter extends BaseFilter implements FilterInterface
|
|||||||
protected function getSubQuery()
|
protected function getSubQuery()
|
||||||
{
|
{
|
||||||
$subquery = $this->db->table(SubtaskModel::TABLE)
|
$subquery = $this->db->table(SubtaskModel::TABLE)
|
||||||
->columns(
|
->columns(SubtaskModel::TABLE.'.task_id')
|
||||||
SubtaskModel::TABLE.'.user_id',
|
|
||||||
SubtaskModel::TABLE.'.task_id',
|
|
||||||
UserModel::TABLE.'.name',
|
|
||||||
UserModel::TABLE.'.username'
|
|
||||||
)
|
|
||||||
->join(UserModel::TABLE, 'id', 'user_id', SubtaskModel::TABLE)
|
->join(UserModel::TABLE, 'id', 'user_id', SubtaskModel::TABLE)
|
||||||
->neq(SubtaskModel::TABLE.'.status', SubtaskModel::STATUS_DONE);
|
->neq(SubtaskModel::TABLE.'.status', SubtaskModel::STATUS_DONE);
|
||||||
|
|
||||||
|
|||||||
@@ -57,37 +57,33 @@ class TaskTagFilter extends BaseFilter implements FilterInterface
|
|||||||
public function apply()
|
public function apply()
|
||||||
{
|
{
|
||||||
if ($this->value === 'none') {
|
if ($this->value === 'none') {
|
||||||
$task_ids = $this->getTaskIdsWithoutTags();
|
$sub_query = $this->getQueryOfTaskIdsWithoutTags();
|
||||||
} else {
|
} else {
|
||||||
$task_ids = $this->getTaskIdsWithGivenTag();
|
$sub_query = $this->getQueryOfTaskIdsWithGivenTag();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (empty($task_ids)) {
|
$this->query->inSubquery(TaskModel::TABLE.'.id', $sub_query);
|
||||||
$task_ids = array(-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->query->in(TaskModel::TABLE.'.id', $task_ids);
|
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function getTaskIdsWithoutTags()
|
protected function getQueryOfTaskIdsWithoutTags()
|
||||||
{
|
{
|
||||||
return $this->db
|
return $this->db
|
||||||
->table(TaskModel::TABLE)
|
->table(TaskModel::TABLE)
|
||||||
|
->columns(TaskModel::TABLE . '.id')
|
||||||
->asc(TaskModel::TABLE . '.project_id')
|
->asc(TaskModel::TABLE . '.project_id')
|
||||||
->left(TaskTagModel::TABLE, 'tg', 'task_id', TaskModel::TABLE, 'id')
|
->left(TaskTagModel::TABLE, 'tg', 'task_id', TaskModel::TABLE, 'id')
|
||||||
->isNull('tg.tag_id')
|
->isNull('tg.tag_id');
|
||||||
->findAllByColumn(TaskModel::TABLE . '.id');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function getTaskIdsWithGivenTag()
|
protected function getQueryOfTaskIdsWithGivenTag()
|
||||||
{
|
{
|
||||||
return $this->db
|
return $this->db
|
||||||
->table(TagModel::TABLE)
|
->table(TagModel::TABLE)
|
||||||
|
->columns(TaskTagModel::TABLE.'.task_id')
|
||||||
->ilike(TagModel::TABLE.'.name', $this->value)
|
->ilike(TagModel::TABLE.'.name', $this->value)
|
||||||
->asc(TagModel::TABLE.'.project_id')
|
->asc(TagModel::TABLE.'.project_id')
|
||||||
->join(TaskTagModel::TABLE, 'tag_id', 'id')
|
->join(TaskTagModel::TABLE, 'tag_id', 'id');
|
||||||
->findAllByColumn(TaskTagModel::TABLE.'.task_id');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user