Simplify dashboard to use new tasks list view
This commit is contained in:
@@ -69,35 +69,6 @@ class SubtaskModel extends Base
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the query to fetch subtasks assigned to a user
|
||||
*
|
||||
* @access public
|
||||
* @param integer $userId
|
||||
* @param array $status
|
||||
* @return \PicoDb\Table
|
||||
*/
|
||||
public function getUserQuery($userId, array $status)
|
||||
{
|
||||
return $this->db->table(SubtaskModel::TABLE)
|
||||
->columns(
|
||||
SubtaskModel::TABLE.'.*',
|
||||
TaskModel::TABLE.'.project_id',
|
||||
TaskModel::TABLE.'.color_id',
|
||||
TaskModel::TABLE.'.title AS task_name',
|
||||
ProjectModel::TABLE.'.name AS project_name'
|
||||
)
|
||||
->subquery($this->subtaskTimeTrackingModel->getTimerQuery($userId), 'timer_start_date')
|
||||
->eq('user_id', $userId)
|
||||
->eq(ProjectModel::TABLE.'.is_active', ProjectModel::ACTIVE)
|
||||
->eq(ColumnModel::TABLE.'.hide_in_dashboard', 0)
|
||||
->in(SubtaskModel::TABLE.'.status', $status)
|
||||
->join(TaskModel::TABLE, 'id', 'task_id')
|
||||
->join(ProjectModel::TABLE, 'id', 'project_id', TaskModel::TABLE)
|
||||
->join(ColumnModel::TABLE, 'id', 'column_id', TaskModel::TABLE)
|
||||
->callback(array($this, 'addStatusName'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get common query
|
||||
*
|
||||
@@ -148,6 +119,24 @@ class SubtaskModel extends Base
|
||||
->format();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get subtasks for a list of tasks and a given assignee
|
||||
*
|
||||
* @param array $taskIds
|
||||
* @param integer $userId
|
||||
* @return array
|
||||
*/
|
||||
public function getAllByTaskIdsAndAssignee(array $taskIds, $userId)
|
||||
{
|
||||
if (empty($taskIds)) {
|
||||
return array();
|
||||
}
|
||||
|
||||
return $this->subtaskListFormatter
|
||||
->withQuery($this->getQuery()->in('task_id', $taskIds)->eq(self::TABLE.'.user_id', $userId))
|
||||
->format();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a subtask by the id
|
||||
*
|
||||
@@ -310,24 +299,4 @@ class SubtaskModel extends Base
|
||||
$values['user_id'] = isset($values['user_id']) ? $values['user_id'] : 0;
|
||||
$this->hook->reference('model:subtask:creation:prepare', $values);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add subtask status status to the resultset
|
||||
*
|
||||
* @access public
|
||||
* @param array $subtasks Subtasks
|
||||
* @return array
|
||||
*/
|
||||
public function addStatusName(array $subtasks)
|
||||
{
|
||||
$status = $this->getStatusList();
|
||||
|
||||
foreach ($subtasks as &$subtask) {
|
||||
$subtask['status_name'] = $status[$subtask['status']];
|
||||
$subtask['timer_start_date'] = isset($subtask['timer_start_date']) ? $subtask['timer_start_date'] : 0;
|
||||
$subtask['is_timer_started'] = ! empty($subtask['timer_start_date']);
|
||||
}
|
||||
|
||||
return $subtasks;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user