diff --git a/module/metric/calc/product/scale/count_of_projected_story_with_case_in_product.php b/module/metric/calc/product/scale/count_of_projected_story_with_case_in_product.php new file mode 100644 index 0000000000..a1d4167c09 --- /dev/null +++ b/module/metric/calc/product/scale/count_of_projected_story_with_case_in_product.php @@ -0,0 +1,50 @@ + + * @package + * @uses func + * @license ZPL(https://zpl.pub/page/zplv12.html) or AGPL(https://www.gnu.org/licenses/agpl-3.0.en.html) + * @Link https://www.zentao.net + */ +class count_of_projected_story_with_case_in_product extends baseCalc +{ + public $result = array(); + + public function getStatement() + { + return $this->dao->select("COUNT(DISTINCT t1.story) as 'value', t1.product") + ->from(TABLE_CASE)->alias('t0') + ->leftJoin(TABLE_PROJECTSTORY)->alias('t1')->on('t1.story=t0.story') + ->leftJoin(TABLE_STORY)->alias('t2')->on('t1.story=t2.id') + ->leftJoin(TABLE_PRODUCT)->alias('t3')->on('t1.product=t3.id') + ->where('t2.deleted')->eq('0') + ->andWhere('t3.deleted')->eq('0') + ->groupBy('t1.product'); + } + + public function calculate($row) + { + $product = $row->product; + $value = $row->value; + + $this->result[$product] = $value; + } + + public function getResult($options = array()) + { + $records = $this->getRecords(array('product', 'value')); + return $this->filterByOptions($records, $options); + } +} diff --git a/module/metric/test/calc/product/scale/count_of_projected_story_with_case_in_product.php b/module/metric/test/calc/product/scale/count_of_projected_story_with_case_in_product.php new file mode 100644 index 0000000000..613699c9cf --- /dev/null +++ b/module/metric/test/calc/product/scale/count_of_projected_story_with_case_in_product.php @@ -0,0 +1,22 @@ +#!/usr/bin/env php +config('product', $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); +zdTable('case')->config('case', $useCommon = true, $levels = 4)->gen(1000); + +$metric = new metricTest(); +$calc = $metric->calcMetric(__FILE__); + +/** + +title=count_of_projected_story_with_case_in_product +cid=1 +pid=1 + +*/ + +r(count($calc->getResult())) && p('') && e('5'); // 测试分组数。