* Fix bug #42480, refresh project stats after man hour changing.
This commit is contained in:
@@ -1356,6 +1356,20 @@ class programModel extends model
|
||||
$this->loadModel('action')->cleanActions();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 刷新项目的统计数据。
|
||||
* Refresh stats fields(estimate,consumed,left,progress) of project.
|
||||
*
|
||||
* @param bool $refreshAll
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function refreshProjectStats(int $projectID): void
|
||||
{
|
||||
$this->programTao->updateStats(array($projectID));
|
||||
}
|
||||
|
||||
/**
|
||||
* Check the privilege.
|
||||
*
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
/**
|
||||
|
||||
title=测试 programTao::refreshProjectStats();
|
||||
timeout=0
|
||||
cid=1
|
||||
|
||||
- 更新项目 11 的统计信息,获取项目 11 的统计信息
|
||||
- 属性progress @25.00
|
||||
- 属性teamCount @4
|
||||
- 属性estimate @46
|
||||
- 属性consumed @13
|
||||
- 属性left @39
|
||||
- 更新项目 60 的统计信息,获取项目 60 的统计信息
|
||||
- 属性progress @31.80
|
||||
- 属性teamCount @0
|
||||
- 属性estimate @18
|
||||
- 属性consumed @7
|
||||
- 属性left @15
|
||||
- 更新项目 61 的统计信息,获取项目 61 的统计信息
|
||||
- 属性progress @0.00
|
||||
- 属性teamCount @0
|
||||
- 属性estimate @0
|
||||
- 属性consumed @0
|
||||
- 属性left @0
|
||||
- 更新项目 100 的统计信息,获取项目 100 的统计信息
|
||||
- 属性progress @0.00
|
||||
- 属性teamCount @0
|
||||
- 属性estimate @0
|
||||
- 属性consumed @0
|
||||
- 属性left @0
|
||||
- 更新不存在的项目 1111 的统计信息,获取不存在的项目 1111 的统计信息
|
||||
- 属性progress @0
|
||||
- 属性teamCount @0
|
||||
- 属性estimate @0
|
||||
- 属性consumed @0
|
||||
- 属性left @0
|
||||
|
||||
*/
|
||||
|
||||
include dirname(__FILE__, 5) . '/test/lib/init.php';
|
||||
include dirname(__FILE__, 2) . '/program.class.php';
|
||||
|
||||
zdTable('project')->config('program')->gen(20);
|
||||
zdTable('task')->config('task')->gen(20);
|
||||
zdTable('team')->config('team')->gen(30);
|
||||
zdTable('user')->gen(5);
|
||||
|
||||
su('admin');
|
||||
|
||||
$projectIdList = array(11, 60, 61, 100, 1111);
|
||||
$programTester = new programTest();
|
||||
|
||||
r($programTester->refreshProjectStatsTest($projectIdList[0])) && p('progress,teamCount,estimate,consumed,left') && e('25.00,4,46,13,39'); // 更新项目 11 的统计信息,获取项目 11 的统计信息
|
||||
r($programTester->refreshProjectStatsTest($projectIdList[1])) && p('progress,teamCount,estimate,consumed,left') && e('31.80,0,18,7,15'); // 更新项目 60 的统计信息,获取项目 60 的统计信息
|
||||
r($programTester->refreshProjectStatsTest($projectIdList[2])) && p('progress,teamCount,estimate,consumed,left') && e('0.00,0,0,0,0'); // 更新项目 61 的统计信息,获取项目 61 的统计信息
|
||||
r($programTester->refreshProjectStatsTest($projectIdList[3])) && p('progress,teamCount,estimate,consumed,left') && e('0.00,0,0,0,0'); // 更新项目 100 的统计信息,获取项目 100 的统计信息
|
||||
r($programTester->refreshProjectStatsTest($projectIdList[4])) && p('progress,teamCount,estimate,consumed,left') && e('0,0,0,0,0'); // 更新不存在的项目 1111 的统计信息,获取不存在的项目 1111 的统计信息
|
||||
@@ -583,4 +583,20 @@ class programTest
|
||||
$program = $this->program->getByID($programID);
|
||||
return $this->program->hasUnfinishedChildren($program);
|
||||
}
|
||||
|
||||
/**
|
||||
* 刷新项目的统计数据。
|
||||
* Refresh stats fields(estimate,consumed,left,progress) of project.
|
||||
*
|
||||
* @param int $projectID
|
||||
* @access public
|
||||
* @return array|object|bool
|
||||
*/
|
||||
public function refreshProjectStatsTest(int $projectID): array|object|bool
|
||||
{
|
||||
$this->program->refreshProjectStats($projectID);
|
||||
if(dao::isError()) return dao::getError();
|
||||
|
||||
return $this->program->dao->select('*')->from(TABLE_PROJECT)->where('id')->eq($projectID)->fetch();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user