From 6efac784fcc1a2e83bb7b43fc7841448b5975cba Mon Sep 17 00:00:00 2001 From: Frederic Guillot Date: Wed, 24 Jun 2015 20:39:06 -0400 Subject: Add timer for subtasks and remove settings for subtask time tracking --- app/Model/Subtask.php | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'app/Model/Subtask.php') diff --git a/app/Model/Subtask.php b/app/Model/Subtask.php index ee000e32..b9cc6ded 100644 --- a/app/Model/Subtask.php +++ b/app/Model/Subtask.php @@ -78,6 +78,8 @@ class Subtask extends Base 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; @@ -101,12 +103,13 @@ class Subtask extends Base Task::TABLE.'.title AS task_name', Project::TABLE.'.name AS project_name' ) + ->subquery($this->subtaskTimeTracking->getTimerQuery($user_id), 'timer_start_date') ->eq('user_id', $user_id) ->eq(Project::TABLE.'.is_active', Project::ACTIVE) ->in(Subtask::TABLE.'.status', $status) ->join(Task::TABLE, 'id', 'task_id') ->join(Project::TABLE, 'id', 'project_id', Task::TABLE) - ->filter(array($this, 'addStatusName')); + ->callback(array($this, 'addStatusName')); } /** @@ -121,10 +124,15 @@ class Subtask extends Base return $this->db ->table(self::TABLE) ->eq('task_id', $task_id) - ->columns(self::TABLE.'.*', User::TABLE.'.username', User::TABLE.'.name') + ->columns( + self::TABLE.'.*', + User::TABLE.'.username', + User::TABLE.'.name' + ) + ->subquery($this->subtaskTimeTracking->getTimerQuery($this->userSession->getId()), 'timer_start_date') ->join(User::TABLE, 'id', 'user_id') ->asc(self::TABLE.'.position') - ->filter(array($this, 'addStatusName')) + ->callback(array($this, 'addStatusName')) ->findAll(); } @@ -144,8 +152,9 @@ class Subtask extends Base ->table(self::TABLE) ->eq(self::TABLE.'.id', $subtask_id) ->columns(self::TABLE.'.*', User::TABLE.'.username', User::TABLE.'.name') + ->subquery($this->subtaskTimeTracking->getTimerQuery($this->userSession->getId()), 'timer_start_date') ->join(User::TABLE, 'id', 'user_id') - ->filter(array($this, 'addStatusName')) + ->callback(array($this, 'addStatusName')) ->findOne(); } -- cgit v1.2.3