Fix issue: task time tracking is not updated when deleting a subtask

This commit is contained in:
Frederic Guillot
2015-09-14 22:10:08 -04:00
parent eaff957839
commit d1e6c39df4
5 changed files with 24 additions and 25 deletions

View File

@@ -339,20 +339,7 @@ class SubtaskTimeTracking extends Base
*/
public function updateTaskTimeTracking($task_id)
{
$result = $this->calculateSubtaskTime($task_id);
$values = array();
if ($result['total_spent'] > 0) {
$values['time_spent'] = $result['total_spent'];
}
if ($result['total_estimated'] > 0) {
$values['time_estimated'] = $result['total_estimated'];
}
if (empty($values)) {
return true;
}
$values = $this->calculateSubtaskTime($task_id);
return $this->db
->table(Task::TABLE)
@@ -373,8 +360,8 @@ class SubtaskTimeTracking extends Base
->table(Subtask::TABLE)
->eq('task_id', $task_id)
->columns(
'SUM(time_spent) AS total_spent',
'SUM(time_estimated) AS total_estimated'
'SUM(time_spent) AS time_spent',
'SUM(time_estimated) AS time_estimated'
)
->findOne();
}

View File

@@ -12,6 +12,7 @@ class SubtaskTimeTrackingSubscriber extends \Core\Base implements EventSubscribe
{
return array(
Subtask::EVENT_CREATE => array('updateTaskTime', 0),
Subtask::EVENT_DELETE => array('updateTaskTime', 0),
Subtask::EVENT_UPDATE => array(
array('logStartEnd', 10),
array('updateTaskTime', 0),