From 8f4fddad4bb12dc79491fc20364c064f35ad7f05 Mon Sep 17 00:00:00 2001 From: songchenxuan Date: Wed, 7 Aug 2024 16:25:32 +0800 Subject: [PATCH] *[task#124858,done,2h]. --- module/bi/config/metrics.php | 14 ++++++ .../count_of_effective_bug_in_execution.php | 43 +++++++++++++++++++ module/metric/dataset.php | 25 +++++++++++ 3 files changed, 82 insertions(+) create mode 100644 module/metric/calc/execution/scale/count_of_effective_bug_in_execution.php diff --git a/module/bi/config/metrics.php b/module/bi/config/metrics.php index 909f852020..d737acbb97 100644 --- a/module/bi/config/metrics.php +++ b/module/bi/config/metrics.php @@ -4396,3 +4396,17 @@ $config->bi->builtin->metrics[] = array 'desc' => '按代码库统计的的每日代码提交次数是指代码库每日的代码提交数量。这个度量项可以反映代码库每日开发活动频率和代码更新情况。', 'definition' => '代码库中代码提交次数求和,提交时间为某日。' ); + +$config->bi->builtin->metrics[] = array +( + 'name' => '按执行统计的新增有效Bug总数', + 'alias' => '新增有效Bug总数', + 'code' => 'count_of_effective_bug_in_execution', + 'purpose' => 'scale', + 'scope' => 'execution', + 'object' => 'bug', + 'unit' => 'count', + 'dateType' => 'nodate', + 'desc' => '按执行统计的新增有效Bug总数是指在执行中发现的有效Bug的数量。这个度量项反映了执行的质量情况。新增有效Bug数越多可能代表执行的代码质量存在的问题越多,需要进行进一步的解决和改进。', + 'definition' => "执行中新增Bug个数求和\n解决方案为已解决,延期处理和不予解决或状态为激活\n过滤已删除的Bug\n过滤已删除的执行\n过滤已删除的项目\n过滤已删除的产品\n" +); diff --git a/module/metric/calc/execution/scale/count_of_effective_bug_in_execution.php b/module/metric/calc/execution/scale/count_of_effective_bug_in_execution.php new file mode 100644 index 0000000000..703ec86b75 --- /dev/null +++ b/module/metric/calc/execution/scale/count_of_effective_bug_in_execution.php @@ -0,0 +1,43 @@ + + * @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_effective_bug_in_execution extends baseCalc +{ + public $dataset = 'getExecutionBugs'; + + public $fieldList = array('t1.execution', 't1.status', 't1.resolution'); + + public $result = array(); + + public function calculate($row) + { + if($row->status == 'active' || in_array($row->resolution, array('fixed', 'postponed', 'willnotfix'))) + { + if(!isset($this->result[$row->execution])) $this->result[$row->execution] = 0; + $this->result[$row->execution] ++; + } + } + + public function getResult($options = array()) + { + $records = $this->getRecords(array('execution', 'value')); + return $this->filterByOptions($records, $options); + } +} diff --git a/module/metric/dataset.php b/module/metric/dataset.php index cdad21e93a..554a2a893e 100644 --- a/module/metric/dataset.php +++ b/module/metric/dataset.php @@ -223,6 +223,31 @@ class dataset return $this->defaultWhere($stmt, 't2'); } + /** + * 获取执行bug数据。 + * Get execution product bug list. + * + * @param string $fieldList + * @access public + * @return PDOStatement + */ + public function getExecutionBugs($fieldList) + { + $stmt = $this->dao->select($fieldList) + ->from(TABLE_BUG)->alias('t1') + ->leftJoin(TABLE_PRODUCT)->alias('t2')->on('t1.product=t2.id') + ->leftJoin(TABLE_PROJECT)->alias('t3')->on('t1.execution=t3.id') + ->leftJoin(TABLE_PROJECT)->alias('t4')->on('t1.project=t4.id') + ->where('t1.deleted')->eq(0) + ->andWhere('t2.deleted')->eq(0) + ->andWhere('t2.shadow')->eq(0) + ->andWhere('t3.deleted')->eq(0) + ->andWhere('t3.type')->in('sprint,stage,kanban') + ->andWhere('t4.deleted')->eq(0); + + return $this->defaultWhere($stmt, 't2'); + } + /** * 获取所有bug数据。 * Get all bug list.