Merge branch dev/story-75273 of zentao/zentaopms (#9275)

This commit is contained in:
刘刚
2025-06-09 15:10:29 +08:00
committed by Gitfox
10 changed files with 431 additions and 0 deletions
+35
View File
@@ -729,4 +729,39 @@ class baseCalc
return $executions;
}
/**
* 检查日期。
* Validate date.
*
* @param string $date
* @access public
* @return bool
*/
public function validateDate(string $date): bool
{
return $this->getYear($date) !== false;
}
/**
* 按日期递增计数。
* Count incrementally by date.
*
* @param int $dataID
* @param string $date
* @access public
* @return void
*/
public function incrementDateCount(int $dataID, string $date)
{
$date = substr($date, 0, 10);
list($year, $month, $day) = explode('-', $date);
if(!isset($this->result[$dataID])) $this->result[$dataID] = array();
if(!isset($this->result[$dataID][$year])) $this->result[$dataID][$year] = array();
if(!isset($this->result[$dataID][$year][$month])) $this->result[$dataID][$year][$month] = array();
if(!isset($this->result[$dataID][$year][$month][$day])) $this->result[$dataID][$year][$month][$day] = 0;
$this->result[$dataID][$year][$month][$day]++;
}
}
@@ -0,0 +1,44 @@
<?php
/**
* 按执行统计的激活Bug数。
* Count of activated bug in execution.
*
* 范围:execution
* 对象:bug
* 目的:scale
* 度量名称:按执行统计的激活Bug数
* 单位:个
* 描述:按执行统计的激活Bug数是指当前未解决的Bug数量。这个度量项反映了执行当前存在的待解决问题数量。激活Bug总数越多可能代表执行的稳定性较低,需要加强Bug解决的速度和质量。
* 定义:执行中Bug个数求和;状态为激活;过滤已删除的Bug;过滤已删除的执行;
*
* @copyright Copyright 2009-2023 禅道软件(青岛)有限公司(ZenTao Software (Qingdao) Co., Ltd. www.zentao.net)
* @author qixinzhi <qixinzhi@easycorp.ltd>
* @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_activated_bug_in_execution extends baseCalc
{
public $dataset = 'getExecutionBugs';
public $fieldList = array('t1.status', 't1.execution');
public $result = array();
public function calculate($row)
{
$execution = $row->execution;
$status = $row->status;
if(!isset($this->result[$execution])) $this->result[$execution] = 0;
if($status == 'active') $this->result[$execution] += 1;
}
public function getResult($options = array())
{
$records = $this->getRecords(array('execution', 'value'));
return $this->filterByOptions($records, $options);
}
}
@@ -0,0 +1,47 @@
<?php
/**
* 按优先级统计的执行下的Bug数。
* Count of bug in pri in execution.
*
* 范围:pri
* 对象:bug
* 目的:scale
* 度量名称:按优先级统计的执行下的Bug数
* 单位:个
* 描述:按优先级统计的执行下的Bug数
* 定义:按优先级统计的执行下的Bug数
*
* @copyright Copyright 2009-2025 禅道软件(青岛)有限公司(ZenTao Software (Qingdao) Co., Ltd. www.zentao.net)
* @author Zemei Wang <wangzemei@easycorp.ltd>
* @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_bug_in_pri_in_execution extends baseCalc
{
public $dataset = 'getExecutionBugs';
public $fieldList = array();
public $result = array();
public function calculate($row)
{
if(!isset($this->result[$row->pri])) $this->result[$row->pri] = array();
$this->result[$row->pri][$row->id] = $row->id;
}
public function getResult($options = array())
{
foreach($this->result as $pri => $bugs)
{
if(!is_array($bugs)) continue;
$this->result[$pri] = count($bugs);
}
$records = $this->getRecords(array('pri', 'value'));
return $this->filterByOptions($records, $options);
}
}
@@ -0,0 +1,47 @@
<?php
/**
* 按解决方案统计的执行下的Bug数。
* Count of bug in resolution in execution.
*
* 范围:resolution
* 对象:bug
* 目的:scale
* 度量名称:按解决方案统计的执行下的Bug数
* 单位:个
* 描述:按解决方案统计的执行下的Bug数
* 定义:按解决方案统计的执行下的Bug数
*
* @copyright Copyright 2009-2025 禅道软件(青岛)有限公司(ZenTao Software (Qingdao) Co., Ltd. www.zentao.net)
* @author Zemei Wang <wangzemei@easycorp.ltd>
* @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_bug_in_resolution_in_execution extends baseCalc
{
public $dataset = 'getExecutionBugs';
public $fieldList = array();
public $result = array();
public function calculate($row)
{
if(!isset($this->result[$row->resolution])) $this->result[$row->resolution] = array();
$this->result[$row->resolution][$row->id] = $row->id;
}
public function getResult($options = array())
{
foreach($this->result as $resolution => $bugs)
{
if(!is_array($bugs)) continue;
$this->result[$resolution] = count($bugs);
}
$records = $this->getRecords(array('resolution', 'value'));
return $this->filterByOptions($records, $options);
}
}
@@ -0,0 +1,47 @@
<?php
/**
* 按严重程度统计的执行下的Bug数。
* Count of bug in severity in execution.
*
* 范围:severity
* 对象:bug
* 目的:scale
* 度量名称:按严重程度统计的执行下的Bug数
* 单位:个
* 描述:按严重程度统计的执行下的Bug数
* 定义:按严重程度统计的执行下的Bug数
*
* @copyright Copyright 2009-2025 禅道软件(青岛)有限公司(ZenTao Software (Qingdao) Co., Ltd. www.zentao.net)
* @author Zemei Wang <wangzemei@easycorp.ltd>
* @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_bug_in_severity_in_execution extends baseCalc
{
public $dataset = 'getExecutionBugs';
public $fieldList = array();
public $result = array();
public function calculate($row)
{
if(!isset($this->result[$row->severity])) $this->result[$row->severity] = array();
$this->result[$row->severity][$row->id] = $row->id;
}
public function getResult($options = array())
{
foreach($this->result as $severity => $bugs)
{
if(!is_array($bugs)) continue;
$this->result[$severity] = count($bugs);
}
$records = $this->getRecords(array('severity', 'value'));
return $this->filterByOptions($records, $options);
}
}
@@ -0,0 +1,47 @@
<?php
/**
* 按类型统计的执行下的Bug数。
* Count of bug in type in execution.
*
* 范围:type
* 对象:bug
* 目的:scale
* 度量名称:按类型统计的执行下的Bug数
* 单位:个
* 描述:按类型统计的执行下的Bug数
* 定义:按类型统计的执行下的Bug数
*
* @copyright Copyright 2009-2025 禅道软件(青岛)有限公司(ZenTao Software (Qingdao) Co., Ltd. www.zentao.net)
* @author Zemei Wang <wangzemei@easycorp.ltd>
* @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_bug_in_type_in_execution extends baseCalc
{
public $dataset = 'getExecutionBugs';
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 => $bugs)
{
if(!is_array($bugs)) continue;
$this->result[$type] = count($bugs);
}
$records = $this->getRecords(array('type', 'value'));
return $this->filterByOptions($records, $options);
}
}
@@ -0,0 +1,43 @@
<?php
/**
* 按执行统计的执行用例产生的Bug总数。
* Count of bug of executing use cases in execution.
*
* 范围:execution
* 对象:bug
* 目的:scale
* 度量名称:按执行统计的执行用例产生的Bug总数
* 单位:个
* 描述:按执行统计的执行用例产生的Bug总数是指在执行中发现的有效Bug的数量。这个度量项反映了执行的质量情况。执行用例产生的Bug数越多可能代表执行的代码质量存在的问题越多,需要进行进一步的解决和改进。
* 定义:执行中新增Bug个数求和;解决方案为已解决、延期处理和不予解决或状态为激活;过滤已删除的执行;过滤已删除的项目;过滤已删除的产品。
*
* @copyright Copyright 2009-2023 禅道软件(青岛)有限公司(ZenTao Software (Qingdao) Co., Ltd. www.zentao.net)
* @author Zemei Wang <wangzemei@easycorp.ltd>
* @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_case_bug_in_execution extends baseCalc
{
public $dataset = 'getExecutionBugs';
public $fieldList = array('t1.execution', 't1.case');
public $result = array();
public function calculate($row)
{
if(!empty($row->case))
{
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);
}
}
@@ -0,0 +1,40 @@
<?php
/**
* 按执行统计的每日关闭Bug数。
* Count of daily closed bug in execution.
*
* 范围:execution
* 对象:bug
* 目的:scale
* 度量名称:按执行统计的每日关闭Bug数
* 单位:个
* 描述:按执行统计的每日关闭Bug数是指每天在执行中每日关闭的Bug的数量。该度量项可以帮助我们了解开发团队对已解决的Bug进行确认与关闭的速度和效率,通过对比不同时间段的关闭Bug数,可以评估开发团队的协作和问题处理能力。
* 定义:执行中Bug数求和,关闭时间为某日,过滤已删除的Bug,过滤已删除的执行。
*
* @copyright Copyright 2009-2024 禅道软件(青岛)有限公司(ZenTao Software (Qingdao) Co., Ltd. www.zentao.net)
* @author songchenxuan <songchenxuan@easycorp.ltd>
* @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_daily_closed_bug_in_execution extends baseCalc
{
public $dataset = 'getExecutionBugs';
public $fieldList = array('t1.execution', 't1.status', 't1.closedDate');
public $result = array();
public function calculate($row)
{
if($row->status != 'closed' || !$this->validateDate($row->closedDate)) return false;
$this->incrementDateCount($row->execution, $row->closedDate);
}
public function getResult($options = array())
{
$records = $this->getRecords(array('execution', 'year', 'month', 'day'));
return $this->filterByOptions($records, $options);
}
}
@@ -0,0 +1,40 @@
<?php
/**
* 按执行统计的每日新增Bug数。
* Count of daily created bug in execution.
*
* 范围:execution
* 对象:bug
* 目的:scale
* 度量名称:按执行统计的每日新增Bug数
* 单位:个
* 描述:按执行统计的每日新增Bug数是指在每天的执行开始后新发现并记录的Bug数量。该度量项可以体现执行开始后Bug的发现速度和趋势,较高的新增Bug数可能意味着存在较多的问题需要解决,同时也可以帮助识别执行开始后的瓶颈和潜在的质量风险。
* 定义:执行中Bug数求和,创建时间为某日,过滤已删除的Bug,过滤已删除的执行。
*
* @copyright Copyright 2009-2024 禅道软件(青岛)有限公司(ZenTao Software (Qingdao) Co., Ltd. www.zentao.net)
* @author songchenxuan <songchenxuan@easycorp.ltd>
* @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_daily_created_bug_in_execution extends baseCalc
{
public $dataset = 'getExecutionBugs';
public $fieldList = array('t1.execution', 't1.openedDate');
public $result = array();
public function calculate($row)
{
if(!$this->validateDate($row->openedDate)) return false;
$this->incrementDateCount($row->execution, $row->openedDate);
}
public function getResult($options = array())
{
$records = $this->getRecords(array('execution', 'year', 'month', 'day', 'value'));
return $this->filterByOptions($records, $options);
}
}
@@ -0,0 +1,41 @@
<?php
/**
* 按执行统计的每日解决Bug数。
* Count of daily resolved bug in execution.
*
* 范围:execution
* 对象:bug
* 目的:scale
* 度量名称:按执行统计的每日解决Bug数
* 单位:个
* 描述:按执行统计的每日解决Bug数是指执行每日解决的Bug的数量。该度量项可以帮助我们了解开发团队解决Bug的速度和效率。
* 定义:执行中Bug数求和,解决日期为某日,过滤已删除的Bug,过滤已删除的执行。
*
* @copyright Copyright 2009-2024 禅道软件(青岛)有限公司(ZenTao Software (Qingdao) Co., Ltd. www.zentao.net)
* @author songchenxuan <songchenxuan@easycorp.ltd>
* @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_daily_resolved_bug_in_execution extends baseCalc
{
public $dataset = 'getExecutionBugs';
public $fieldList = array('t1.execution', 't1.status', 't1.resolvedDate');
public $result = array();
public function calculate($row)
{
if($row->status == 'active' || !$this->validateDate($row->resolvedDate)) return false;
$this->incrementDateCount($row->execution, $row->resolvedDate);
}
public function getResult($options = array())
{
$records = $this->getRecords(array('execution', 'year', 'month', 'day', 'value'));
return $this->filterByOptions($records, $options);
}
}