+ Add fetchBurnData method.
This commit is contained in:
@@ -11,6 +11,57 @@ declare(strict_types=1);
|
||||
*/
|
||||
class executionTao extends executionModel
|
||||
{
|
||||
/**
|
||||
* 获取燃尽图相关数据。
|
||||
* Get burn related data.
|
||||
*
|
||||
* @param array $executionIdList
|
||||
* @access protected
|
||||
* @return array
|
||||
*/
|
||||
protected function fetchBurnData(array $executionIdList): array
|
||||
{
|
||||
$today = helper::today();
|
||||
$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($executionIdList)
|
||||
->andWhere('deleted')->eq('0')
|
||||
->andWhere('parent')->ge('0')
|
||||
->andWhere('status')->ne('cancel')
|
||||
->groupBy('execution')
|
||||
->fetchAll('execution');
|
||||
|
||||
$closedLefts = $this->dao->select('execution, sum(`left`) AS `left`')->from(TABLE_TASK)
|
||||
->where('execution')->in($executionIdList)
|
||||
->andWhere('deleted')->eq('0')
|
||||
->andWhere('parent')->ge('0')
|
||||
->andWhere('status')->eq('closed')
|
||||
->groupBy('execution')
|
||||
->fetchAll('execution');
|
||||
|
||||
$finishedEstimates = $this->dao->select("execution, sum(`estimate`) AS `estimate`")->from(TABLE_TASK)
|
||||
->where('execution')->in($executionIdList)
|
||||
->andWhere('deleted')->eq('0')
|
||||
->andWhere('parent')->ge('0')
|
||||
->andWhere('status', true)->eq('done')
|
||||
->orWhere('status')->eq('closed')
|
||||
->markRight(1)
|
||||
->groupBy('execution')
|
||||
->fetchAll('execution');
|
||||
|
||||
$storyPoints = $this->dao->select('t1.project, sum(t2.estimate) AS `storyPoint`')->from(TABLE_PROJECTSTORY)->alias('t1')
|
||||
->leftJoin(TABLE_STORY)->alias('t2')->on('t1.story = t2.id')
|
||||
->leftJoin(TABLE_PRODUCT)->alias('t3')->on('t2.product = t3.id')
|
||||
->where('t1.project')->in($executionIdList)
|
||||
->andWhere('t2.deleted')->eq(0)
|
||||
->andWhere('t2.status')->ne('closed')
|
||||
->andWhere('t2.stage')->in('wait,planned,projected,developing')
|
||||
->groupBy('project')
|
||||
->fetchAll('project');
|
||||
|
||||
return array($burns, $closedLefts, $finishedEstimates, $storyPoints);
|
||||
}
|
||||
|
||||
/**
|
||||
* 将执行ID保存到session中。
|
||||
* Save the execution ID to the session.
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
include dirname(__FILE__, 5) . '/test/lib/init.php';
|
||||
zdTable('user')->gen(5);
|
||||
su('admin');
|
||||
|
||||
$execution = zdTable('project');
|
||||
$execution->id->range('1-5');
|
||||
$execution->name->range('项目集1,项目1,迭代1,阶段1,看板1');
|
||||
$execution->type->range('program,project,sprint,stage,kanban');
|
||||
$execution->code->range('1-5')->prefix('code');
|
||||
$execution->parent->range('0,1,2{3}');
|
||||
$execution->status->range('wait{3},suspended,closed,doing');
|
||||
$execution->openedBy->range('admin,user1');
|
||||
$execution->begin->range('20220112 000000:0')->type('timestamp')->format('YY/MM/DD');
|
||||
$execution->end->range('20220212 000000:0')->type('timestamp')->format('YY/MM/DD');
|
||||
$execution->gen(5);
|
||||
|
||||
$burn = zdTable('burn');
|
||||
$burn->execution->range('3{5},4{5},5{5}');
|
||||
$burn->date->range('20220111 000000:1D')->type('timestamp')->format('YY/MM/DD');
|
||||
$burn->estimate->range('94.3,56.3,55.3,37.8,33.8');
|
||||
$burn->left->range('95.3,68.5,73.9,40.2,36,3');
|
||||
$burn->consumed->range('20.1,33.4,41,56.55,59.55');
|
||||
$burn->storyPoint->range('0,16.5,16,11.5,9');
|
||||
$burn->gen(15);
|
||||
|
||||
$task = zdTable('task');
|
||||
$task->id->range('1-10');
|
||||
$task->execution->range('3');
|
||||
$task->status->range('wait,doing');
|
||||
$task->estimate->range('1-10');
|
||||
$task->left->range('1-10');
|
||||
$task->consumed->range('1-10');
|
||||
$task->gen(10);
|
||||
|
||||
/**
|
||||
|
||||
title=测试 executionModel->fetchBurnData();
|
||||
timeout=0
|
||||
cid=1
|
||||
|
||||
*/
|
||||
|
||||
global $tester;
|
||||
$executionModel = $tester->loadModel('execution');
|
||||
|
||||
r(current($tester->execution->fetchBurnData(array()))) && p('0:execution,estimate') && e('0,0'); // 测试空数据
|
||||
r(current($tester->execution->fetchBurnData(array(2, 3, 4)))) && p('3:execution,estimate') && e('3,55'); // 测试获取燃尽图数据
|
||||
r(current($tester->execution->fetchBurnData(array(7, 8, 9)))) && p('0:execution,estimate') && e('0, 0'); // 测试获取不存在的执行的燃尽图数据
|
||||
Reference in New Issue
Block a user