* Finish task#99597.
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
/**
|
||||
* 按项目统计的年度完成研发需求规模数。
|
||||
* Scale of annual finished story in project.
|
||||
*
|
||||
* 范围:project
|
||||
* 对象:story
|
||||
* 目的:scale
|
||||
* 度量名称:按项目统计的年度完成研发需求规模数
|
||||
* 单位:sp/工时/功能点
|
||||
* 描述:按项目统计的年度完成研发需求数是指在某年度已关闭且关闭原因为已完成的研发需求规模数。这个度量项可以反映项目团队在某年度的开发效率和成果。完成研发需求规模数的增加说明项目团队在该年度内取得了更多的开发成果和交付物。
|
||||
* 定义:项目中研发需求的规模数求和;关闭时间在某年;关闭原因为已完成;过滤已删除的研发需求;过滤已删除的项目;
|
||||
* 度量库:
|
||||
* 收集方式:realtime
|
||||
*
|
||||
* @copyright Copyright 2009-2023 禅道软件(青岛)有限公司(ZenTao Software (Qingdao) Co., Ltd. www.zentao.net)
|
||||
* @author qixinzhi <qixinzhi@easycorp.ltd>
|
||||
* @package
|
||||
* @uses func
|
||||
* @license ZPL(https://zpl.pub/page/zplv12.html) or AGPL(https://www.gnu.org/licenses/agpl-3.0.en.html)
|
||||
* @Link https://www.zentao.net
|
||||
*/
|
||||
class scale_of_annual_finished_story_in_project extends baseCalc
|
||||
{
|
||||
public $dataset = 'getDevStoriesWithProject';
|
||||
|
||||
public $fieldList = array('t3.project', 't1.closedDate', 't1.closedReason', 't1.estimate');
|
||||
|
||||
public $result = array();
|
||||
|
||||
public function calculate($row)
|
||||
{
|
||||
$project = $row->project;
|
||||
$closedDate = $row->closedDate;
|
||||
|
||||
if(empty($closedDate)) return false;
|
||||
$year = substr($closedDate, 0, 4);
|
||||
if($year == '0000') return false;
|
||||
|
||||
if(!isset($this->result[$project])) $this->result[$project] = array();
|
||||
if(!isset($this->result[$project][$year])) $this->result[$project][$year] = 0;
|
||||
|
||||
if($row->closedReason == 'done') $this->result[$project][$year] += $row->estimate;
|
||||
}
|
||||
|
||||
public function getResult($options = array())
|
||||
{
|
||||
$records = $this->getRecords(array('project', 'year', 'value'));
|
||||
return $this->filterByOptions($records, $options);
|
||||
}
|
||||
}
|
||||
Regular → Executable
Regular → Executable
Regular → Executable
@@ -21,4 +21,4 @@ pid=1
|
||||
|
||||
r(count($calc->getResult())) && p('') && e('18'); // 测试分组数。
|
||||
|
||||
r($calc->getResult(array('project' => '4'))) && p('0:value') && e('1'); // 测试项目2。
|
||||
r($calc->getResult(array('project' => '9', 'year' => '2018'))) && p('0:value') && e('3'); // 测试项目2。
|
||||
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
include dirname(__FILE__, 7) . '/test/lib/init.php';
|
||||
include dirname(__FILE__, 4) . '/calc.class.php';
|
||||
|
||||
zdTable('product')->config('product', $useCommon = true, $levels = 4)->gen(10);
|
||||
zdTable('project')->config('project_close', $useCommon = true, $levels = 4)->gen(10);
|
||||
zdTable('story')->config('story_status_closedreason', $useCommon = true, $levels = 4)->gen(1000);
|
||||
zdTable('projectstory')->config('projectstory', $useCommon = true, $levels = 4)->gen(1000);
|
||||
|
||||
$metric = new metricTest();
|
||||
$calc = $metric->calcMetric(__FILE__);
|
||||
|
||||
/**
|
||||
|
||||
title=scale_of_annual_finished_story_in_project
|
||||
cid=1
|
||||
pid=1
|
||||
|
||||
*/
|
||||
|
||||
r(count($calc->getResult())) && p('') && e('18'); // 测试分组数。
|
||||
|
||||
r($calc->getResult(array('project' => '9', 'year' => '2018'))) && p('0:value') && e('15'); // 测试项目2。
|
||||
Reference in New Issue
Block a user