* Finish task#98387.
This commit is contained in:
@@ -45,14 +45,7 @@ class scale_of_monthly_closed_story extends baseCalc
|
||||
|
||||
public function getResult($options = array())
|
||||
{
|
||||
$records = array();
|
||||
foreach($this->result as $year => $months)
|
||||
{
|
||||
foreach($months as $month => $value)
|
||||
{
|
||||
$records[] = array('year' => $year, 'month' => $month, 'value' => $value);
|
||||
}
|
||||
}
|
||||
$records = $this->getRecords(array('year', 'month', 'value'));
|
||||
return $this->filterByOptions($records, $options);
|
||||
}
|
||||
}
|
||||
|
||||
+21
-11
@@ -10,9 +10,9 @@
|
||||
* 单位:个
|
||||
* 描述:按全局统计的月度完成研发需求规模数表示某月度完成的研发需求的规模总数。该度量项反映了组织每月完成的研发需求的规模总数,可以用于评估组织的研发需求规模管理和效果。
|
||||
* 定义:所有的研发需求规模数求和
|
||||
关闭时间为某年某月
|
||||
关闭原因为已完成
|
||||
过滤已删除的研发需求
|
||||
* 关闭时间为某年某月
|
||||
* 关闭原因为已完成
|
||||
* 过滤已删除的研发需求
|
||||
* 度量库:
|
||||
* 收集方式:realtime
|
||||
*
|
||||
@@ -25,20 +25,30 @@
|
||||
*/
|
||||
class scale_of_monthly_finished_story extends baseCalc
|
||||
{
|
||||
public $dataset = null;
|
||||
public $dataset = 'getDevStories';
|
||||
|
||||
public $fieldList = array();
|
||||
public $fieldList = array('t1.closedDate', 't1.closedReason', 't1.estimate');
|
||||
|
||||
//public funtion getStatement($dao)
|
||||
//{
|
||||
//}
|
||||
public $result = array();
|
||||
|
||||
public function calculate($data)
|
||||
public function calculate($row)
|
||||
{
|
||||
if(empty($row->closedDate) || $row->closedReason != 'done') return false;
|
||||
|
||||
$year = substr($row->closedDate, 0, 4);
|
||||
$month = substr($row->closedDate, 5, 2);
|
||||
|
||||
if($year == '0000') return false;
|
||||
|
||||
if(!isset($this->result[$year])) $this->result[$year] = array();
|
||||
if(!isset($this->result[$year][$month])) $this->result[$year][$month] = 0;
|
||||
|
||||
$this->result[$year][$month] += $row->estimate;
|
||||
}
|
||||
|
||||
public function getResult($options = array())
|
||||
{
|
||||
return $this->filterByOptions($this->result, $options);
|
||||
$records = $this->getRecords(array('year', 'month', 'value'));
|
||||
return $this->filterByOptions($records, $options);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
#!/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('story')->config('story_status_closedreason', $useCommon = true, $levels = 4)->gen(1000);
|
||||
|
||||
$metric = new metricTest();
|
||||
$calc = $metric->calcMetric(__FILE__);
|
||||
|
||||
/**
|
||||
|
||||
title=scale_of_monthly_finished_story
|
||||
cid=1
|
||||
pid=1
|
||||
|
||||
*/
|
||||
|
||||
r(count($calc->getResult())) && p('') && e('38'); // 测试按产品的月度完成需求分组数。
|
||||
|
||||
r($calc->getResult(array('year' => '2019', 'month' => '01'))) && p('0:value') && e('0'); // 测试2019年1月完成的需求数。
|
||||
r($calc->getResult(array('year' => '2019', 'month' => '06'))) && p('0:value') && e('5'); // 测试2019年6月完成的需求数。
|
||||
r($calc->getResult(array('year' => '2020', 'month' => '08'))) && p('0:value') && e('1'); // 测试2020年8月完成的需求数。
|
||||
r($calc->getResult(array('year' => '2020', 'month' => '10'))) && p('0:value') && e('1'); // 测试2020年10月完成的需求数。
|
||||
r($calc->getResult(array('year' => '2021', 'month' => '04'))) && p('') && e('0'); // 测试不存在的产品的需求数。
|
||||
Reference in New Issue
Block a user