From eca1d0969b4aee8cdd7365ffa74237f2038481c7 Mon Sep 17 00:00:00 2001 From: caoyanyi Date: Fri, 13 Jun 2025 16:19:13 +0800 Subject: [PATCH] + [task#144597,doing,0.4h] add count_of_story_in_type_in_product metric. --- .../count_of_story_in_type_in_product.php | 50 +++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 module/metric/calc/product/scale/count_of_story_in_type_in_product.php 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); + } +}