diff --git a/module/metric/calc/product/scale/count_of_story_in_type_in_product.php b/module/metric/calc/product/scale/count_of_story_in_type_in_product.php new file mode 100644 index 0000000000..7c8d88dc8c --- /dev/null +++ b/module/metric/calc/product/scale/count_of_story_in_type_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_story_in_type_in_product extends baseCalc +{ + public $dataset = ''; + + public $fieldList = array(); + + public $result = array(); + + public function calculate($row) + { + if(!isset($this->result[$row->type])) $this->result[$row->type] = array(); + $this->result[$row->type][$row->id] = $row->id; + } + + public function getResult($options = array()) + { + foreach($this->result as $type => $stories) + { + if(!is_array($stories)) + { + unset($this->result[$type]); + continue; + } + $this->result[$type] = count($stories); + } + + $records = $this->getRecords(array('type', 'value')); + return $this->filterByOptions($records, $options); + } +}