* Finish task#97122.
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
/**
|
||||
* 按产品统计的年度已完成研发需求规模数。
|
||||
* .
|
||||
* Scale of annual finished story in product.
|
||||
*
|
||||
* 范围:product
|
||||
* 对象:story
|
||||
@@ -9,8 +9,8 @@
|
||||
* 度量名称:按产品统计的年度已完成研发需求规模数
|
||||
* 单位:sp/工时/功能点
|
||||
* 描述:产品中关闭时间在某年且关闭原因为已完成的研发需求的规模数求和
|
||||
过滤已删除的研发需求
|
||||
过滤已删除的产品
|
||||
* 过滤已删除的研发需求
|
||||
* 过滤已删除的产品
|
||||
* 度量库:
|
||||
* 收集方式:realtime
|
||||
*
|
||||
@@ -23,21 +23,40 @@
|
||||
*/
|
||||
class scale_of_annual_finished_story_in_product extends baseCalc
|
||||
{
|
||||
public $dataset = '';
|
||||
public $dataset = 'getStories';
|
||||
|
||||
public $fieldList = array();
|
||||
public $fieldList = array('t1.product', 't1.closedDate', 't1.closedReason', 't1.estimate');
|
||||
|
||||
public $result = array();
|
||||
|
||||
//public function getStatement()
|
||||
//{
|
||||
//}
|
||||
public function calculate($data)
|
||||
{
|
||||
$product = $data->product;
|
||||
$closedDate = $data->closedDate;
|
||||
$closedReason = $data->closedReason;
|
||||
$estimate = $data->estimate;
|
||||
|
||||
//public function calculate($data)
|
||||
//{
|
||||
//}
|
||||
$year = substr($closedDate, 0, 4);
|
||||
|
||||
//public function getResult()
|
||||
//{
|
||||
//}
|
||||
}
|
||||
if($year == '0000') return;
|
||||
|
||||
if(!isset($this->result[$product])) $this->result[$product] = array();
|
||||
if(!isset($this->result[$product][$year])) $this->result[$product][$year] = 0;
|
||||
|
||||
if($closedReason == 'done') $this->result[$product][$year] += $estimate;
|
||||
}
|
||||
|
||||
public function getResult($options = null)
|
||||
{
|
||||
$records = array();
|
||||
foreach($this->result as $product => $years)
|
||||
{
|
||||
foreach($years as $year => $value)
|
||||
{
|
||||
$records[] = array('product' => $product, 'year' => $year, 'value' => $value);
|
||||
}
|
||||
}
|
||||
|
||||
return $this->filterByOptions($records, $options);
|
||||
}
|
||||
}
|
||||
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
include dirname(__FILE__, 7) . '/test/lib/init.php';
|
||||
include dirname(__FILE__, 4) . '/calc.class.php';
|
||||
|
||||
zdTable('product')->gen(200);
|
||||
zdTable('story')->config('story_close')->gen(5000);
|
||||
|
||||
$metric = new metricTest();
|
||||
$calc = $metric->calcMetric(__FILE__);
|
||||
|
||||
/**
|
||||
|
||||
title=scale_of_annual_finished_story_in_product
|
||||
cid=1
|
||||
pid=1
|
||||
|
||||
*/
|
||||
r(count($calc->getResult())) && p('') && e('371'); // 测试按产品的年度完成需求分组数。
|
||||
|
||||
r($calc->getResult(array('product' => '16', 'year' => '2019'))) && p('0:value') && e('18'); // 测试2019年产品16关闭的需求规模数。
|
||||
r($calc->getResult(array('product' => '78', 'year' => '2020'))) && p('0:value') && e('9'); // 测试2020年产品78关闭的需求规模数。
|
||||
r($calc->getResult(array('product' => '999', 'year' => '2021'))) && p('') && e('0'); // 测试不存在的产品的需求规模数。
|
||||
Regular → Executable
+16
@@ -0,0 +1,16 @@
|
||||
---
|
||||
title: zt_story
|
||||
author: qixinzhi
|
||||
version: "1.0"
|
||||
fields:
|
||||
- field: id
|
||||
range: 1-10000
|
||||
- field: product
|
||||
range: 1-100{10}
|
||||
- field: estimate
|
||||
range: 1-10
|
||||
- field: closedDate
|
||||
range: (-5Y)-(-10M)-(+1w):-1D
|
||||
type: timestamp
|
||||
format: YYYY-MM-DD hh:mm:ss
|
||||
...
|
||||
Reference in New Issue
Block a user