* Finish task#99184.
This commit is contained in:
+10
-7
@@ -22,21 +22,24 @@
|
||||
*/
|
||||
class count_of_finished_story_in_project extends baseCalc
|
||||
{
|
||||
public $dataset = null;
|
||||
public $dataset = 'getDevStoriesWithProject';
|
||||
|
||||
public $fieldList = array();
|
||||
public $fieldList = array('t3.project', 't1.closedReason');
|
||||
|
||||
//public funtion getStatement($dao)
|
||||
//{
|
||||
//}
|
||||
public $result = array();
|
||||
|
||||
public function calculate($row)
|
||||
{
|
||||
$project = $row->project;
|
||||
$closedReason = $row->closedReason;
|
||||
|
||||
if(!isset($this->result[$project])) $this->result[$project] = 0;
|
||||
if($closedReason == 'done') $this->result[$project] += 1;
|
||||
}
|
||||
|
||||
public function getResult($options = array())
|
||||
{
|
||||
$records = $this->getRecords(array('value'));
|
||||
$records = $this->getRecords(array('project', 'value'));
|
||||
return $this->filterByOptions($records, $options);
|
||||
}
|
||||
}
|
||||
}
|
||||
+24
@@ -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('project')->config('project_close', $useCommon = true, $levels = 4)->gen(10);
|
||||
zdTable('story')->config('story_status_closedreason', $useCommon = true, $levels = 4)->gen(1000);
|
||||
zdTable('projectstory')->config('projectstory', $useCommon = true, $levels = 4)->gen(1000);
|
||||
|
||||
$metric = new metricTest();
|
||||
$calc = $metric->calcMetric(__FILE__);
|
||||
|
||||
/**
|
||||
|
||||
title=count_of_finished_story_in_project
|
||||
cid=1
|
||||
pid=1
|
||||
|
||||
*/
|
||||
|
||||
r(count($calc->getResult())) && p('') && e('6'); // 测试分组数。
|
||||
|
||||
r($calc->getResult(array('project' => '4'))) && p('0:value') && e('3'); // 测试。
|
||||
Reference in New Issue
Block a user