* Finish task#98221.

This commit is contained in:
qixinzhi
2023-07-20 06:54:55 +00:00
parent bf081e8033
commit f112160074
4 changed files with 56 additions and 17 deletions
@@ -34,8 +34,7 @@ class count_of_annual_created_story extends baseCalc
if(empty($openedDate)) return;
$year = substr($openedDate, 0, 4);
$year = substr($openedDate, 0, 4);
if($year == '0000') return;
if(!isset($this->result[$year])) $this->result[$year] = 0;
@@ -1,7 +1,7 @@
<?php
/**
* 按产品统计的年度修复Bug数。
* .
* Count of annual restored bug in product.
*
* 范围:product
* 对象:Bug
@@ -9,8 +9,8 @@
* 度量名称:按产品统计的年度修复Bug数
* 单位:个
* 描述:产品中关闭时间为某年且解决方案为已解决的Bug的个数求和
过滤已删除的Bug
过滤已删除的产品
* 过滤已删除的Bug
* 过滤已删除的产品
* 度量库:
* 收集方式:realtime
*
@@ -23,21 +23,33 @@
*/
class count_of_annual_restored_bug_in_product extends baseCalc
{
public $dataset = '';
public $dataset = 'getBugs';
public $fieldList = array();
public $fieldList = array('t1.resolution', 't1.closedDate');
public $result = array();
//public function getStatement()
//{
//}
public function calculate($data)
{
$resolution = $data->resolution;
$closedDate = $data->closedDate;
//public function calculate($data)
//{
//}
if(empty($closedDate)) return;
//public function getResult()
//{
//}
}
$year = substr($closedDate, 0, 4);
if($resolution != 'fixed' || $year == '0000') return;
if(!isset($this->result[$year])) $this->result[$year] = 0;
$this->result[$year] += 1;
}
public function getResult($options = array())
{
$records = array();
foreach($this->result as $year => $value)
{
$records[] = array('year' => $year, 'value' => $value);
}
return $this->filterByOptions($records, $options);
}
}
@@ -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('bug')->config('bug_resolution_status', $useCommon = true, $levels = 4)->gen(1000);
zdTable('product')->config('product', $useCommon = true, $levels = 4)->gen(10);
$metric = new metricTest();
$calc = $metric->calcMetric(__FILE__);
/**
title=count_of_annual_restored_story_in_product
timeout=0
cid=1
*/
r(count($calc->getResult())) && p('') && e('7'); // 测试分组数。
r($calc->getResult(array('product' => '3', 'year' => '2015'))) && p('0:value') && e('6'); // 测试2015年产品3修复的bug数。
r($calc->getResult(array('product' => '5', 'year' => '2016'))) && p('0:value') && e('0'); // 测试2016年产品5修复的bug数。
r($calc->getResult(array('product' => '4', 'year' => '2019'))) && p('0:value') && e('0'); // 测试已删除产品4修复的bug数。
r($calc->getResult(array('product' => '999', '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: closedDate
range: "20120101 000000-20220101 230000:10D"
type: timestamp
format: YYYY-MM-DD hh:mm:ss
- field: status
range: active{1},resolved{1},closed{1}
- field: resolution