diff --git a/module/metric/calc/global/scale/count_of_unclosed_story.php b/module/metric/calc/global/scale/count_of_unclosed_story.php index 7dcf7a10e9..c77d30b2b2 100644 --- a/module/metric/calc/global/scale/count_of_unclosed_story.php +++ b/module/metric/calc/global/scale/count_of_unclosed_story.php @@ -10,9 +10,9 @@ * 单位:个 * 描述:按全局统计的未关闭研发需求数表示尚未完成的研发需求的数量。该度量项反映了组织中尚未完成并关闭的研发需求的数量,可以用于评估组织的研发需求执行进展和挑战。 * 定义:复用: -按全局统计的研发需求总数 -按全局统计的已关闭研发需求数 -公式:按全局统计的未关闭研发需求数=按全局统计的研发需求总数-按全局统计的已关闭研发需求数 + * 按全局统计的研发需求总数 + * 按全局统计的已关闭研发需求数 + * 公式:按全局统计的未关闭研发需求数=按全局统计的研发需求总数-按全局统计的已关闭研发需求数 * 度量库: * 收集方式:realtime * @@ -25,20 +25,21 @@ */ class count_of_unclosed_story extends baseCalc { - public $dataset = null; + public $dataset = 'getDevStories'; - public $fieldList = array(); + public $fieldList = array('t1.stage'); - //public funtion getStatement($dao) - //{ - //} + public $result = 0; public function calculate($data) { + $stage = $data->stage; + if($stage != 'closed') $this->result ++; } public function getResult($options = array()) { + $records = array(array('value' => $this->result)); return $this->filterByOptions($this->result, $options); } -} \ No newline at end of file +} diff --git a/module/metric/test/calc/global/scale/count_of_unclosed_story.php b/module/metric/test/calc/global/scale/count_of_unclosed_story.php new file mode 100755 index 0000000000..c181c93a93 --- /dev/null +++ b/module/metric/test/calc/global/scale/count_of_unclosed_story.php @@ -0,0 +1,27 @@ +#!/usr/bin/env php +config('product', $useCommon = true, $levels = 4)->gen(10); +zdTable('story')->config('story_stage', $useCommon = true, $levels = 4)->gen(839, true, false); +$calc = $metric->calcMetric(__FILE__); +r($calc->getResult()) && p('0:value') && e('189'); // 测试839条数据全局未关闭研发需求数。 + +zdTable('story')->config('story_stage', $useCommon = true, $levels = 4)->gen(500, true, false); +$calc = $metric->calcMetric(__FILE__); +r($calc->getResult()) && p('0:value') && e('117'); // 测试500条数据全局未关闭研发需求数。 + +zdTable('story')->config('story_stage', $useCommon = true, $levels = 4)->gen(1252, true, false); +$calc = $metric->calcMetric(__FILE__); +r($calc->getResult()) && p('0:value') && e('288'); // 测试1252条数据全局未关闭研发需求数。 diff --git a/module/metric/test/yaml/story_stage.yaml b/module/metric/test/yaml/story_stage.yaml new file mode 100644 index 0000000000..4c708a1d44 --- /dev/null +++ b/module/metric/test/yaml/story_stage.yaml @@ -0,0 +1,26 @@ +--- +title: zt_story +author: qixinzhi +version: "1.0" +fields: +- field: id + range: 1-10000 +- field: product + range: 1-10{20} +- field: openedDate + range: "20100101 000000-20210101 230000:10D" + type: timestamp + format: YYYY-MM-DD hh:mm:ss +- field: closedDate + range: "20110101 000000-20210101 230000:10D" + type: timestamp + format: YYYY-MM-DD hh:mm:ss +- field: estimate + range: 1-10{10} +- field: stage + range: wait{1},planned{1},projected{1},developing{1},developed{1},testing{1},tested{1},verified{1},released{1},closed{1} +- field: type + range: story +- field: deleted + range: 0{10},1{10} +...