* Finish task#97968.

This commit is contained in:
qixinzhi
2023-07-18 07:13:00 +00:00
parent ce616ddcae
commit 756c65b64e
4 changed files with 51 additions and 42 deletions
@@ -24,20 +24,30 @@
*/
class count_of_annual_created_story extends baseCalc
{
public $dataset = null;
public $dataset = 'getDevStories';
public $fieldList = array();
//public funtion getStatement($dao)
//{
//}
public $fieldList = array('t1.openedDate');
public function calculate($data)
{
$openedDate = $data->openedDate;
$year = substr($openedDate, 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,23 @@
#!/usr/bin/env php
<?php
include dirname(__FILE__, 7) . '/test/lib/init.php';
include dirname(__FILE__, 4) . '/calc.class.php';
zdTable('story')->config('story_status', $useCommon = true, $levels = 4)->gen(1000);
$metric = new metricTest();
$calc = $metric->calcMetric(__FILE__);
/**
title=count_of_annual_created_story
timeout=0
cid=1
*/
r(count($calc->getResult())) && p('') && e('11'); // 测试按产品的年度新增需求分组数。
r($calc->getResult(array('year' => '2019'))) && p('0:value') && e('39'); // 测试2019年新增的需求数。
r($calc->getResult(array('year' => '2020'))) && p('0:value') && e('36'); // 测试2020年新增的需求数。
r($calc->getResult(array('year' => '2021'))) && p('') && e('0'); // 测试不存在的产品的需求数。
@@ -14,24 +14,12 @@ title=count_of_monthly_created_story
timeout=0
cid=1
- 测试按产品的月度新增需求分组数。 @126
- 测试2017年4月新增的需求数。第0条的value属性 @2
- 测试2017年5月新增的需求数。第0条的value属性 @2
- 测试2013年3月新增的需求数。第0条的value属性 @5
- 测试2013年4月新增的需求数。第0条的value属性 @4
- 测试不存在的产品的需求数。 @0
*/
r(count($calc->getResult())) && p('') && e('126'); // 测试按产品的月度新增需求分组数。
r($calc->getResult(array('year' => '2019', 'month' => '07'))) && p('0:value') && e('2'); // 测试2017年4月新增的需求数。
r($calc->getResult(array('year' => '2019', 'month' => '10'))) && p('0:value') && e('2'); // 测试2017年5月新增的需求数。
r($calc->getResult(array('year' => '2020', 'month' => '02'))) && p('0:value') && e('5'); // 测试2013年3月新增的需求数。
r($calc->getResult(array('year' => '2020', 'month' => '03'))) && p('0:value') && e('4'); // 测试2013年4月新增的需求数。
r($calc->getResult(array('year' => '2021', 'month' => '04'))) && p('') && e('0'); // 测试不存在的产品的需求数。
r($calc->getResult(array('year' => '2019', 'month' => '07'))) && p('0:value') && e('2'); // 测试2019年7月新增的需求数。
r($calc->getResult(array('year' => '2019', 'month' => '10'))) && p('0:value') && e('2'); // 测试2019年10月新增的需求数。
r($calc->getResult(array('year' => '2020', 'month' => '02'))) && p('0:value') && e('5'); // 测试2020年2月新增的需求数。
r($calc->getResult(array('year' => '2020', 'month' => '03'))) && p('0:value') && e('4'); // 测试2020年3月新增的需求数。
r($calc->getResult(array('year' => '2021', 'month' => '04'))) && p('') && e('0'); // 测试不存在的产品的需求数。
@@ -14,24 +14,12 @@ title=count_of_monthly_finished_story
timeout=0
cid=1
- 测试按产品的月度完成需求分组数。 @120
- 测试2017年4月完成的需求数。第0条的value属性 @3
- 测试2017年5月完成的需求数。第0条的value属性 @3
- 测试2013年3月完成的需求数。第0条的value属性 @4
- 测试2013年4月完成的需求数。第0条的value属性 @3
- 测试不存在的产品的需求数。 @0
*/
r(count($calc->getResult())) && p('') && e('120'); // 测试按产品的月度完成需求分组数。
r($calc->getResult(array('year' => '2019', 'month' => '07'))) && p('0:value') && e('3'); // 测试2017年4月完成的需求数。
r($calc->getResult(array('year' => '2019', 'month' => '10'))) && p('0:value') && e('3'); // 测试2017年5月完成的需求数。
r($calc->getResult(array('year' => '2020', 'month' => '02'))) && p('0:value') && e('4'); // 测试2013年3月完成的需求数。
r($calc->getResult(array('year' => '2020', 'month' => '03'))) && p('0:value') && e('3'); // 测试2013年4月完成的需求数。
r($calc->getResult(array('year' => '2021', 'month' => '04'))) && p('') && e('0'); // 测试不存在的产品的需求数。
r($calc->getResult(array('year' => '2019', 'month' => '07'))) && p('0:value') && e('3'); // 测试2019年7月完成的需求数。
r($calc->getResult(array('year' => '2019', 'month' => '10'))) && p('0:value') && e('3'); // 测试2019年10月完成的需求数。
r($calc->getResult(array('year' => '2020', 'month' => '02'))) && p('0:value') && e('4'); // 测试2020年2月完成的需求数。
r($calc->getResult(array('year' => '2020', 'month' => '03'))) && p('0:value') && e('3'); // 测试2020年3月完成的需求数。
r($calc->getResult(array('year' => '2021', 'month' => '04'))) && p('') && e('0'); // 测试不存在的产品的需求数。