Skip to content
Permalink
Browse files

fixed the dynamic task calculation

The way this query was originally built, it was counting dynamic tasks
that were children even though it was already counting their children.
Therefore, everything was roughly doubled.
Resolves issue #1423
  • Loading branch information
caseysoftware committed Dec 22, 2013
1 parent 9299d6b commit 2d7a3bb25bc100408c4b45a45b2b7b76a44d6d80
Showing with 4 additions and 10 deletions.
  1. +4 −10 modules/tasks/tasks.class.php
@@ -432,25 +432,20 @@ public function updateDynamics()
$q->addQuery('SUM(task_log_hours)');
$q->addWhere("task_path_enumeration LIKE '$path/%' AND task_dynamic <> 1");
$children_hours_worked = (float) $q->loadResult();
//Collect worked hours based on dynamic children tasks
$q->clear();
$q->addTable('tasks');
$q->addQuery('SUM(task_hours_worked)');
$q->addWhere("task_path_enumeration LIKE '$path/%' AND task_dynamic = 1");
$children_hours_worked += (float) $q->loadResult();

//Collect percent complete based on tasks with duration type of 'hours'
$q->clear();
$q->addTable('tasks');
$q->addQuery('SUM(task_percent_complete * task_duration * task_duration_type)');
$q->addWhere("task_path_enumeration LIKE '$path/%' AND task_duration_type = 1 ");
$q->addQuery('SUM(task_percent_complete * task_duration)');
$q->addWhere("task_path_enumeration LIKE '$path/%' AND task_duration_type = 1 AND task_dynamic <> 1");
$weighted_hours_worked = (float) $q->loadResult();
//Collect percent complete based on tasks with duration type of 'days'
$q->clear();
$q->addTable('tasks');
$q->addQuery('SUM(task_percent_complete * task_duration * ' . w2PgetConfig('daily_working_hours') . ')');
$q->addWhere("task_path_enumeration LIKE '$path/%' AND task_duration_type <> 1 ");
$q->addWhere("task_path_enumeration LIKE '$path/%' AND task_duration_type <> 1 AND task_dynamic <> 1");
$weighted_hours_worked += (float) $q->loadResult();

if (0 == $children_allocated_total) {
$percent_complete = 0;
} else {
@@ -468,7 +463,6 @@ public function updateDynamics()
$q->addWhere("task_id = $key");
$q->exec();
}

CProject::updateHoursWorked((int) $this->task_project);
}

0 comments on commit 2d7a3bb

Please sign in to comment.
You can’t perform that action at this time.