* Finish task#98218.
This commit is contained in:
@@ -9,10 +9,10 @@
|
||||
* 度量名称:按产品统计的严重程度为1、2级的Bug数
|
||||
* 单位:个
|
||||
* 描述:复用:
|
||||
按产品统计的严重程度为1级的Bug数
|
||||
按产品统计的严重程度为2级的Bug数
|
||||
公式:
|
||||
按产品统计的严重程度为1、2级的Bug数=按产品统计的严重程度为1级的Bug数+按产品统计的严重程度为2级的Bug数
|
||||
* 按产品统计的严重程度为1级的Bug数
|
||||
* 按产品统计的严重程度为2级的Bug数
|
||||
* 公式:
|
||||
* 按产品统计的严重程度为1、2级的Bug数=按产品统计的严重程度为1级的Bug数+按产品统计的严重程度为2级的Bug数
|
||||
* 度量库:
|
||||
* 收集方式:realtime
|
||||
*
|
||||
@@ -25,21 +25,30 @@
|
||||
*/
|
||||
class count_of_severe_bug_in_product extends baseCalc
|
||||
{
|
||||
public $dataset = '';
|
||||
public $dataset = 'getBugs';
|
||||
|
||||
public $fieldList = array();
|
||||
public $fieldList = array('t1.severity', 't1.product');
|
||||
|
||||
public $result = array();
|
||||
|
||||
//public function getStatement()
|
||||
//{
|
||||
//}
|
||||
public function calculate($data)
|
||||
{
|
||||
$severity = $data->severity;
|
||||
$product = $data->product;
|
||||
|
||||
//public function calculate($data)
|
||||
//{
|
||||
//}
|
||||
if(!isset($this->result[$product])) $this->result[$product] = 0;
|
||||
|
||||
//public function getResult()
|
||||
//{
|
||||
//}
|
||||
}
|
||||
if($severity == '1' || $severity == '2') $this->result[$product] += 1;
|
||||
}
|
||||
|
||||
public function getResult($options = array())
|
||||
{
|
||||
$records = array();
|
||||
foreach($this->result as $product => $value)
|
||||
{
|
||||
$records[] = array('product' => $product, '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('product')->config('product', $useCommon = true, $levels = 4)->gen(10);
|
||||
zdTable('bug')->config('bug_severity', $useCommon = true, $levels = 4)->gen(1000);
|
||||
|
||||
$metric = new metricTest();
|
||||
$calc = $metric->calcMetric(__FILE__);
|
||||
|
||||
/**
|
||||
|
||||
title=count_of_severe_bug_in_product
|
||||
cid=1
|
||||
pid=1
|
||||
|
||||
*/
|
||||
|
||||
r(count($calc->getResult())) && p('') && e('5'); // 测试严重程度1、2级bug按产品分组数。
|
||||
r($calc->getResult(array('product' => '1'))) && p('0:value') && e('36'); // 测试产品1严重程度1、2级的bug数。
|
||||
r($calc->getResult(array('product' => '3'))) && p('0:value') && e('40'); // 测试产品3严重程度1、2级的bug数。
|
||||
r($calc->getResult(array('product' => '4'))) && p('0:value') && e('0'); // 测试已删除产品4严重程度1、2级的bug数。
|
||||
r($calc->getResult(array('product' => '999'))) && p('') && e('0'); // 测试不存在的产品严重程度1、2级的bug数。
|
||||
@@ -0,0 +1,26 @@
|
||||
---
|
||||
title: zt_bug
|
||||
author: qixinzhi
|
||||
version: "1.0"
|
||||
fields:
|
||||
- field: id
|
||||
range: 1-10000
|
||||
- field: product
|
||||
range: 1-10{8}
|
||||
- field: openedDate
|
||||
range: "20100101 000000-20210101 230000:10D"
|
||||
type: timestamp
|
||||
format: YYYY-MM-DD hh:mm:ss
|
||||
- field: resolvedDate
|
||||
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: severity
|
||||
range: 1{10},2{10},3{5},4{3}
|
||||
- field: deleted
|
||||
range: 0{4},1{4}
|
||||
...
|
||||
Reference in New Issue
Block a user