* Finish task#97972.

This commit is contained in:
qixinzhi
2023-07-20 05:55:43 +00:00
parent 0c1b9a48f4
commit cc00e81a3d
3 changed files with 57 additions and 9 deletions
@@ -10,7 +10,7 @@
* 单位:个
* 描述:按全局统计的年度交付研发需求数表示每年交付的研发需求的数量。该度量项反映了组织每年交付给用户的研发需求数量,可以用于评估组织的研发需求交付效能和效果。
* 定义:所有的所处阶段为已发布且发布时间为某年或关闭原因为已完成且关闭时间为某年的研发需求个数求和
过滤已删除的研发需求
* 过滤已删除的研发需求
* 度量库:
* 收集方式:realtime
*
@@ -23,20 +23,38 @@
*/
class count_of_annual_delivered_story extends baseCalc
{
public $dataset = null;
public $dataset = 'getDevStories';
public $fieldList = array();
//public funtion getStatement($dao)
//{
//}
public $fieldList = array('t1.stage', 't1.releasedDate', 't1.closedReason', 't1.closedDate');
public function calculate($data)
{
$stage = $data->stage;
$closedReason = $data->closedReason;
$releasedDate = $data->releasedDate;
$closedDate = $data->closedDate;
$date = null;
if($closedReason == 'done') $date = $closedDate;
if($stage == 'released' && !empty($closedDate)) $date = $releasedDate;
if($date === null) return;
$year = substr($date, 0, 4);
if($year == '0000') return;
if(!isset($this->result[$year])) $this->result[$year] = 0;
$this->result[$year] += 1;
}
public function getResult($options = array())
{
return $this->filterByOptions($this->result, $options);
$records = array();
foreach($this->result as $year => $value)
{
$records[] = array('year' => $year, 'value' => $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_stage_closedreason', $useCommon = true, $levels = 4)->gen(2000);
$metric = new metricTest();
$calc = $metric->calcMetric(__FILE__);
/**
title=count_of_annual_delivered_story
timeout=0
cid=1
*/
r(count($calc->getResult())) && p('') && e('10'); // 测试按产品的年度交付研发需求分组数。
r($calc->getResult(array('year' => '2019'))) && p('0:value') && e('22'); // 测试2019年交付的研发需求数。
r($calc->getResult(array('year' => '2019'))) && p('0:value') && e('22'); // 测试2019年交付的研发需求数。
r($calc->getResult(array('year' => '2020'))) && p('0:value') && e('8'); // 测试2020年交付的研发需求数。
r($calc->getResult(array('year' => '2020'))) && p('0:value') && e('8'); // 测试2020年交付的研发需求数。
r($calc->getResult(array('year' => '2021'))) && p('') && e('0'); // 测试不存在的产品的需求数。
@@ -15,6 +15,10 @@ fields:
range: "20110101 000000-20210101 230000:10D"
type: timestamp
format: YYYY-MM-DD hh:mm:ss
- field: releasedDate
range: "20110101 000000-20210101 230000:10D"
type: timestamp
format: YYYY-MM-DD hh:mm:ss
- field: estimate
range: 1-10{10}
- field: stage