This commit is contained in:
chaideqing
2023-12-18 01:11:27 +00:00
parent b03d06530a
commit 999768f6d0
+29 -8
View File
@@ -1325,7 +1325,29 @@ class programModel extends model
if(empty($projects)) return;
}
/* 1. Get summary and members of executions to be refreshed. */
$summary = array();
/* 1. Execution has no tasks.*/
foreach($projects as $project)
{
$executions = $this->dao->select('id')->from(TABLE_PROJECT)->where('project')->eq($project->project)->andWhere('deleted')->eq(0)->fetchPairs();
foreach($executions as $executionID)
{
$taskCount = $this->dao->select('id')->from(TABLE_TASK)
->where('deleted')->eq(0)
->andWhere('execution')->eq($executionID)
->count();
if(empty($taskCount))
{
$summary[$executionID] = new stdclass();
$summary[$executionID]->totalEstimate = 0;
$summary[$executionID]->totalConsumed = 0;
$summary[$executionID]->totalLeft = 0;
$summary[$executionID]->execution = $executionID;
}
}
}
/* 2. Get summary and members of executions to be refreshed. */
$tasks = $this->dao->select('t1.id, execution, t1.estimate, t1.consumed, t1.`left`, t1.status')->from(TABLE_TASK)->alias('t1')
->leftJoin(TABLE_PROJECT)->alias('t2')->on('t1.project=t2.id')
->where('t1.deleted')->eq(0)
@@ -1333,7 +1355,6 @@ class programModel extends model
->beginIF(!empty($projects))->andWhere('t1.project')->in(array_keys($projects))->fi()
->fetchAll('id');
$summary = array();
foreach($tasks as $task)
{
if(empty($task->execution)) continue;
@@ -1361,14 +1382,14 @@ class programModel extends model
$projectsPairs = $this->dao->select('id,deleted')->from(TABLE_PROJECT)->fetchPairs();
/* 2. Get all parents to be refreshed. */
/* 3. Get all parents to be refreshed. */
$executions = array();
foreach($summary as $execution) $executions[$execution->execution] = $execution->execution;
$paths = $this->dao->select('id,path')->from(TABLE_PROJECT)->where('id')->in($executions)->fetchAll();
$executionPaths = array();
foreach($paths as $path) $executionPaths[$path->id] = explode(',', trim($path->path, ','));
/* 3. Compute stats of execution and parents. */
/* 4. Compute stats of execution and parents. */
$stats = array();
foreach($summary as $execution)
{
@@ -1395,7 +1416,7 @@ class programModel extends model
$stats[$projectID]['teamCount'] = $teamCount;
}
/* 4. Refresh stats to db. */
/* 5. Refresh stats to db. */
foreach($stats as $projectID => $project)
{
$totalRealNotDel = $project['totalConsumedNotDel'] + $project['totalLeftNotDel'];
@@ -1410,7 +1431,7 @@ class programModel extends model
->exec();
}
/* 5. Update programStatsTime. */
/* 6. Update programStatsTime. */
$projectList = $this->dao->select('id,progress,path,consumed,`left`')->from(TABLE_PROJECT)
->where('type')->eq('project')
->andWhere('parent')->ne(0)
@@ -1438,11 +1459,11 @@ class programModel extends model
$this->dao->update(TABLE_PROJECT)->set('progress')->eq($progress)->where('id')->eq($programID)->exec();
}
/* 6. Update projectStatsTime in config. */
/* 7. Update projectStatsTime in config. */
$this->loadModel('setting')->setItem('system.common.global.projectStatsTime', $now);
$this->app->config->global->projectStatsTime = $now;
/* 7. Clear actions older than 30 days. */
/* 8. Clear actions older than 30 days. */
$this->loadModel('action')->cleanActions();
}