From 2c33a1110c832b721e4e0d6bd2c744d32d1ef600 Mon Sep 17 00:00:00 2001 From: songchenxuan Date: Thu, 31 Oct 2024 16:13:58 +0800 Subject: [PATCH] +[misc] add count_of_annual_created_bug_in_project class. --- ...count_of_annual_created_bug_in_project.php | 56 +++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 module/metric/calc/project/scale/count_of_annual_created_bug_in_project.php diff --git a/module/metric/calc/project/scale/count_of_annual_created_bug_in_project.php b/module/metric/calc/project/scale/count_of_annual_created_bug_in_project.php new file mode 100644 index 0000000000..74fc8086ef --- /dev/null +++ b/module/metric/calc/project/scale/count_of_annual_created_bug_in_project.php @@ -0,0 +1,56 @@ + + * @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_annual_created_bug_in_project extends baseCalc +{ + public $dataset = 'getProjectBugs'; + + public $fieldList = array('t1.openedDate', 't1.project'); + + public $result = array(); + + public function calculate($data) + { + $project = $data->project; + $openedDate = $data->openedDate; + if(empty($openedDate)) return false; + + $year = substr($openedDate, 0, 4); + if($year == '0000') return false; + + if(!isset($this->result[$project])) $this->result[$project] = array(); + if(!isset($this->result[$project][$year])) $this->result[$project][$year] = 0; + $this->result[$project][$year] += 1; + } + + public function getResult($options = array()) + { + $records = array(); + foreach($this->result as $project => $years) + { + foreach($years as $year => $value) + { + $records[] = array('project' => $project, 'year' => $year, 'value' => $value); + } + } + + return $this->filterByOptions($records, $options); + } +}