* Finish task#53671.

This commit is contained in:
xieqiyu
2022-05-11 09:01:17 +08:00
parent 5ddd054b28
commit c77a6505d3
2 changed files with 66 additions and 7 deletions
+61 -5
View File
@@ -2791,15 +2791,69 @@ class executionModel extends model
public function computeBurn()
{
$today = helper::today();
$burns = array();
$executions = $this->dao->select('id, code')->from(TABLE_EXECUTION)
->where('end')->ge($today)
->andWhere('type')->ne('ops')
->andWhere('type')->in('sprint,stage')
->andWhere('status')->notin('done,closed,suspended')
->fetchPairs();
if(!$executions) return $burns;
if(!$executions) return array();
/* Update historical data of burn. */
$table = $this->config->edition == 'open' ? TABLE_TASKESTIMATE : TABLE_EFFORT;
$field = $this->config->edition == 'open' ? 'task' : 'objectID';
$totalConsumed = $this->dao->select("t2.execution as execution, t1.$field as task, t1.date as date, sum(t1.consumed) as totalConsumed")->from($table)->alias('t1')
->leftJoin(TABLE_TASK)->alias('t2')->on("t1.$field=t2.id")
->where('t2.execution')->in(array_keys($executions))
->beginIF($this->config->edition != 'open')->andWhere('t1.objectType')->eq('task')->fi()
->andWhere('t2.deleted')->eq('0')
->andWhere('t2.parent')->ge('0')
->andWhere('t2.status')->ne('cancel')
->andWhere('t1.date')->ne($today)
->groupBy("t1.$field, t1.date")
->orderBy('t1.id_desc')
->fetchGroup('task', 'date');
$maxIDList = $this->dao->select('max(id) as id')->from($table)
->where($field)->in(array_keys($totalConsumed))
->beginIF($this->config->edition != 'open')->andWhere('objectType')->eq('task')->fi()
->groupBy("$field,date")->fetchAll('id');
$lefts = $this->dao->select("$field, date, `left`")->from($table)
->where('id')->in(array_keys($maxIDList))
->fetchGroup($field, 'date');
$burnList = array();
foreach($totalConsumed as $taskID => $consumedList)
{
foreach($consumedList as $date => $consumed)
{
$executionID = $consumed->execution;
if(!isset($burnList[$executionID])) $burnList[$executionID] = array();
if(!isset($burnList[$executionID][$date]))
{
$burnList[$executionID][$date] = new stdclass();
$burnList[$executionID][$date]->consumed = 0;
$burnList[$executionID][$date]->left = 0;
}
$burnList[$executionID][$date]->consumed += $consumed->totalConsumed;
$burnList[$executionID][$date]->left += $lefts[$taskID][$date]->left;
}
}
foreach($burnList as $executionID => $burns)
{
foreach($burns as $date => $burn)
{
$burn->execution = $executionID;
$burn->date = $date;
$this->dao->replace(TABLE_BURN)->data($burn)->exec();
$burn->executionName = $executions[$burn->execution];
}
}
/* Update today's data of burn. */
$burns = $this->dao->select("execution, '$today' AS date, sum(estimate) AS `estimate`, sum(`left`) AS `left`, SUM(consumed) AS `consumed`")
->from(TABLE_TASK)
->where('execution')->in(array_keys($executions))
@@ -2851,8 +2905,10 @@ class executionModel extends model
$this->dao->replace(TABLE_BURN)->data($burn)->exec();
$burn->executionName = $executions[$burn->execution];
$burnList[$executionID][$today] = $burn;
}
return $burns;
return $burnList;
}
/**
+5 -2
View File
@@ -11,8 +11,11 @@
*/
?>
<?php
foreach($burns as $burn)
foreach($burns as $executionID => $burnList)
{
echo $burn->execution . "\t" . $burn->executionName . "\t" . $burn->date . "\t" . $burn->left . "\n";
foreach($burnList as $date => $burn)
{
echo $burn->execution . "\t" . $burn->executionName . "\t" . $burn->date . "\t" . $burn->left . "\n";
}
}
?>