* getdataoftasksperexecution method
This commit is contained in:
+6
-11
@@ -3193,7 +3193,7 @@ class taskModel extends model
|
||||
/* Set closed realname. */
|
||||
if($task->assignedTo == 'closed') $task->assignedToRealName = 'Closed';
|
||||
|
||||
$task->progress = $this->taskTao->computeTaskProgress();
|
||||
$task->progress = $this->taskTao->computeTaskProgress($task);
|
||||
|
||||
if($task->mode == 'multi')
|
||||
{
|
||||
@@ -3268,25 +3268,20 @@ class taskModel extends model
|
||||
}
|
||||
|
||||
/**
|
||||
* Get report data of tasks per execution
|
||||
* Get report data of tasks per execution.
|
||||
*
|
||||
* @access public
|
||||
* @return array
|
||||
* @return object[]
|
||||
*/
|
||||
public function getDataOfTasksPerExecution()
|
||||
public function getDataOfTasksPerExecution(): array
|
||||
{
|
||||
$tasks = $this->dao->select('id,execution')->from(TABLE_TASK)->alias('t1')
|
||||
->where($this->reportCondition())
|
||||
->fetchAll('id');
|
||||
$tasks = $this->taskTao->getListByReportCondition('execution', $this->reportCondition());
|
||||
if(!$tasks) return array();
|
||||
|
||||
$datas = $this->processData4Report($tasks, '', 'execution');
|
||||
|
||||
$executions = $this->loadModel('execution')->getPairs(0, 'all', 'all');
|
||||
foreach($datas as $executionID => $data)
|
||||
{
|
||||
$data->name = isset($executions[$executionID]) ? $executions[$executionID] : $this->lang->report->undefined;
|
||||
}
|
||||
foreach($datas as $executionID => $data) $data->name = isset($executions[$executionID]) ? $executions[$executionID] : $this->lang->report->undefined;
|
||||
return $datas;
|
||||
}
|
||||
|
||||
|
||||
+18
-1
@@ -20,7 +20,7 @@ class taskTao extends taskModel
|
||||
* @access private
|
||||
* @return int
|
||||
*/
|
||||
protected function computeTaskProgress(object $task): int
|
||||
protected function computeTaskProgress(object $task): float
|
||||
{
|
||||
if($task->consumed == 0 and $task->left == 0)
|
||||
{
|
||||
@@ -135,4 +135,21 @@ class taskTao extends taskModel
|
||||
{
|
||||
return $this->dao->select('*')->from(TABLE_TASKTEAM)->where('task')->in($taskIdList)->fetchGroup('task');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get task list by report.
|
||||
* 根据报表条件查询任务.
|
||||
*
|
||||
* @param string $field
|
||||
* @param string $condition
|
||||
* @access public
|
||||
* @return ojbect[]
|
||||
*/
|
||||
protected function getListByReportCondition(string $field, string $condition): array
|
||||
{
|
||||
$tasks = $this->dao->select("id,{$field}")->from(TABLE_TASK)
|
||||
->where($condition)
|
||||
->fetchAll('id');
|
||||
return $tasks;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,27 +4,55 @@ include dirname(__FILE__, 5) . "/test/lib/init.php";
|
||||
include dirname(__FILE__, 2) . '/task.class.php';
|
||||
su('admin');
|
||||
|
||||
function initData()
|
||||
{
|
||||
$project = zdTable('project');
|
||||
$project->id->range('2-5');
|
||||
$project->project->range('6-9');
|
||||
$project->name->prefix("迭代")->range('2-5');
|
||||
$project->code->prefix("project")->range('2-5');
|
||||
$project->auth->range("[]");
|
||||
$project->path->range("`,6,2,`,`,7,3,`,`,8,4,`,`,9,5,`");
|
||||
$project->type->range("sprint");
|
||||
$project->grade->range("1");
|
||||
$project->days->range("1");
|
||||
$project->status->range("wait");
|
||||
$project->desc->range("[]");
|
||||
$project->budget->range("100000,200000");
|
||||
$project->budgetUnit->range("CNY");
|
||||
$project->percent->range("0-0");
|
||||
|
||||
$project->gen(4);
|
||||
|
||||
$task = zdTable('task');
|
||||
$task->id->range('2-5');
|
||||
$task->execution->range('2,3,3,4');
|
||||
$task->name->prefix("任务")->range('1-5');
|
||||
$task->status->range("wait");
|
||||
|
||||
$task->gen(4);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
title=taskModel->getDataOfTasksPerExecution();
|
||||
timeout=0
|
||||
cid=1
|
||||
pid=1
|
||||
|
||||
统计executionID为101的执行的任务数量 >> 迭代1,14
|
||||
统计executionID为102的执行的任务数量 >> 迭代2,4
|
||||
统计executionID为103的执行的任务数量 >> 迭代3,4
|
||||
统计executionID为104的执行的任务数量 >> 迭代4,4
|
||||
统计executionID为105的执行的任务数量 >> 迭代5,4
|
||||
统计executionID为106的执行的任务数量 >> 迭代6,4
|
||||
统计executionID为107的执行的任务数量 >> 迭代7,4
|
||||
- 执行task模块的getDataOfTasksPerExecution方法,参数是2
|
||||
- 第2条的name属性 @/迭代2
|
||||
- 第2条的value属性 @1
|
||||
|
||||
- 执行task模块的getDataOfTasksPerExecution方法,参数是3
|
||||
- 第3条的name属性 @/迭代3
|
||||
- 第3条的value属性 @2
|
||||
|
||||
|
||||
|
||||
*/
|
||||
|
||||
initData();
|
||||
$tester->session->set('taskOnlyCondition', true);
|
||||
$task = new taskTest();
|
||||
r($task->getDataOfTasksPerExecutionTest()) && p('101:name,value') && e('迭代1,14'); //统计executionID为101的执行的任务数量
|
||||
r($task->getDataOfTasksPerExecutionTest()) && p('102:name,value') && e('迭代2,4'); //统计executionID为102的执行的任务数量
|
||||
r($task->getDataOfTasksPerExecutionTest()) && p('103:name,value') && e('迭代3,4'); //统计executionID为103的执行的任务数量
|
||||
r($task->getDataOfTasksPerExecutionTest()) && p('104:name,value') && e('迭代4,4'); //统计executionID为104的执行的任务数量
|
||||
r($task->getDataOfTasksPerExecutionTest()) && p('105:name,value') && e('迭代5,4'); //统计executionID为105的执行的任务数量
|
||||
r($task->getDataOfTasksPerExecutionTest()) && p('106:name,value') && e('迭代6,4'); //统计executionID为106的执行的任务数量
|
||||
r($task->getDataOfTasksPerExecutionTest()) && p('107:name,value') && e('迭代7,4'); //统计executionID为107的执行的任务数量
|
||||
r($task->getDataOfTasksPerExecutionTest(2)) && p('2:name,value') && e('/迭代2,1'); //统计executionID为2的执行的任务数量
|
||||
r($task->getDataOfTasksPerExecutionTest(3)) && p('3:name,value') && e('/迭代3,2'); //统计executionID为3的执行的任务数量
|
||||
@@ -1026,11 +1026,14 @@ class taskTest
|
||||
/**
|
||||
* Test get report data of tasks per execution.
|
||||
*
|
||||
* @param int $executionID
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function getDataOfTasksPerExecutionTest()
|
||||
public function getDataOfTasksPerExecutionTest($executionID)
|
||||
{
|
||||
global $tester;
|
||||
$tester->session->set('taskQueryCondition', "execution = '{$executionID}' AND status IN ('','wait','doing','done','pause','cancel') AND deleted = '0'");
|
||||
$object = $this->objectModel->getDataOfTasksPerExecution();
|
||||
|
||||
if(dao::isError())
|
||||
|
||||
Reference in New Issue
Block a user