* Fix bug#38285.

This commit is contained in:
chaideqing
2023-09-12 03:30:59 +00:00
parent f835bdd96a
commit 6e238c09ca
+18 -5
View File
@@ -1314,11 +1314,11 @@ class programModel extends model
$projects = array();
if($updateTime < date('Y-m-d', strtotime('-14 days')) or $refreshAll)
{
$projects = $this->dao->select('id,project,model')->from(TABLE_PROJECT)->fetchAll('id');
$projects = $this->dao->select('id,project,model,deleted')->from(TABLE_PROJECT)->fetchAll('id');
}
else
{
$projects = $this->dao->select('distinct t1.project,t2.model')->from(TABLE_ACTION)->alias('t1')
$projects = $this->dao->select('distinct t1.project,t2.model,t2.deleted')->from(TABLE_ACTION)->alias('t1')
->leftJoin(TABLE_PROJECT)->alias('t2')->on('t1.project=t2.id')
->where('t1.`date`')->ge($updateTime)
->fetchAll('project');
@@ -1342,6 +1342,8 @@ class programModel extends model
->groupBy('t1.root')
->fetchPairs('root');
$projectsPairs = $this->dao->select('id,deleted')->from(TABLE_PROJECT)->fetchPairs();
/* 2. Get all parents to be refreshed. */
$executions = array();
foreach($summary as $execution) $executions[$execution->execution] = $execution->execution;
@@ -1356,10 +1358,15 @@ class programModel extends model
$executionID = $execution->execution;
foreach($executionPaths[$executionID] as $nodeID)
{
if(!isset($stats[$nodeID])) $stats[$nodeID] = array('totalEstimate' => 0, 'totalConsumed' => 0, 'totalLeft' => 0, 'teamCount' => 0);
if(!isset($stats[$nodeID])) $stats[$nodeID] = array('totalEstimate' => 0, 'totalConsumed' => 0, 'totalLeft' => 0, 'teamCount' => 0, 'totalLeftNotDel' => 0, 'totalConsumedNotDel' => 0);
$stats[$nodeID]['totalEstimate'] += $execution->totalEstimate;
$stats[$nodeID]['totalConsumed'] += $execution->totalConsumed;
$stats[$nodeID]['totalLeft'] += $execution->totalLeft;
if(empty($projectsPairs[$execution->execution]) && empty($projectsPairs[$nodeID]))
{
$stats[$nodeID]['totalConsumedNotDel'] += $execution->totalConsumed;
$stats[$nodeID]['totalLeftNotDel'] += $execution->totalLeft;
}
}
}
@@ -1372,6 +1379,11 @@ class programModel extends model
$stats[$projectID]['totalEstimate'] = $projectStats['PV'];
$stats[$projectID]['totalConsumed'] = $projectStats['AC'];
$stats[$projectID]['totalLeft'] = $projectStats['left'];
if(empty($project->deleted))
{
$stats[$projectID]['totalConsumedNotDel'] = $projectStats['AC'];
$stats[$projectID]['totalLeftNotDel'] = $projectStats['left'];
}
}
foreach($teamMembers as $projectID => $teamCount)
@@ -1383,8 +1395,8 @@ class programModel extends model
/* 4. Refresh stats to db. */
foreach($stats as $projectID => $project)
{
$totalReal = $project['totalConsumed'] + $project['totalLeft'];
$progress = $totalReal ? floor($project['totalConsumed'] / $totalReal * 1000) / 1000 * 100 : 0;
$totalRealNotDel = $project['totalConsumedNotDel'] + $project['totalLeftNotDel'];
$progress = $totalRealNotDel ? floor($project['totalConsumedNotDel'] / $totalRealNotDel * 1000) / 1000 * 100 : 0;
$this->dao->update(TABLE_PROJECT)
->set('progress')->eq($progress)
->set('teamCount')->eq($project['teamCount'])
@@ -1399,6 +1411,7 @@ class programModel extends model
$projectList = $this->dao->select('id,progress,path')->from(TABLE_PROJECT)
->where('type')->eq('project')
->andWhere('parent')->ne(0)
->andWhere('deleted')->eq(0)
->fetchAll('id');
$programProgress = array();
foreach($projectList as $projectID => $project)