diff --git a/module/metric/calc/global/scale/count_of_monthly_closed_project.php b/module/metric/calc/global/scale/count_of_monthly_closed_project.php index eadba7b5b9..7b8a7dcb0c 100644 --- a/module/metric/calc/global/scale/count_of_monthly_closed_project.php +++ b/module/metric/calc/global/scale/count_of_monthly_closed_project.php @@ -10,13 +10,13 @@ * 单位:个 * 描述:按全局统计的年度关闭项目数是指在某月度关闭的项目数量。这个度量项可以帮助团队了解某年度项目的执行情况和成果,并进行项目交付能力的评估。较高的年度关闭项目数表明团队在项目交付方面具有较高的效率。 * 定义:所有的项目个数求和 -关闭时间为某年某月 -过滤已删除的项目 + * 关闭时间为某年某月 + * 过滤已删除的项目 * 度量库: * 收集方式:realtime * * @copyright Copyright 2009-2023 禅道软件(青岛)有限公司(ZenTao Software (Qingdao) Co., Ltd. www.zentao.net) - * @author qixinzhi + * @author zhouxin * @package * @uses func * @license ZPL(https://zpl.pub/page/zplv12.html) or AGPL(https://www.gnu.org/licenses/agpl-3.0.en.html) @@ -24,20 +24,35 @@ */ class count_of_monthly_closed_project extends baseCalc { - public $dataset = null; + public $dataset = 'getAllProjects'; - public $fieldList = array(); + public $fieldList = array('status', 'closedDate'); - //public funtion getStatement($dao) - //{ - //} - - public function calculate($data) + public function calculate($row) { + if(empty($row->closedDate) || $row->status != 'closed') return; + + $year = substr($row->closedDate, 0, 4); + $month = substr($row->closedDate, 5, 2); + + if($year == '0000') return; + + if(!isset($this->result[$year])) $this->result[$year] = array(); + if(!isset($this->result[$year][$month])) $this->result[$year][$month] = 0; + + $this->result[$year][$month] += 1; } public function getResult($options = array()) { - return $this->filterByOptions($this->result, $options); + $records = array(); + foreach($this->result as $year => $months) + { + foreach($months as $month => $value) + { + $records[] = array('year' => $year, 'month' => $month, 'value' => $value); + } + } + return $this->filterByOptions($records, $options); } -} \ No newline at end of file +} diff --git a/module/metric/calc/global/scale/count_of_monthly_created_project.php b/module/metric/calc/global/scale/count_of_monthly_created_project.php index 0cc33f8ea3..a2db5d2543 100644 --- a/module/metric/calc/global/scale/count_of_monthly_created_project.php +++ b/module/metric/calc/global/scale/count_of_monthly_created_project.php @@ -10,13 +10,13 @@ * 单位:个 * 描述:按全局统计的月度新增项目数是指在某月度新启动的项目数量。这个度量项可以帮助团队了解某年度项目规模和工作负荷,以及项目管理和资源分配的需求。较高的年度新增项目数可能需要团队根据资源和能力进行优先级和规划管理。 * 定义:所有的项目个数求和 -创建时间为某年某月 -过滤已删除的项目 + * 创建时间为某年某月 + * 过滤已删除的项目 * 度量库: * 收集方式:realtime * * @copyright Copyright 2009-2023 禅道软件(青岛)有限公司(ZenTao Software (Qingdao) Co., Ltd. www.zentao.net) - * @author qixinzhi + * @author zhouxin * @package * @uses func * @license ZPL(https://zpl.pub/page/zplv12.html) or AGPL(https://www.gnu.org/licenses/agpl-3.0.en.html) @@ -24,20 +24,35 @@ */ class count_of_monthly_created_project extends baseCalc { - public $dataset = null; + public $dataset = 'getAllProjects'; - public $fieldList = array(); + public $fieldList = array('openedDate'); - //public funtion getStatement($dao) - //{ - //} - - public function calculate($data) + public function calculate($row) { + if(empty($row->openedDate)) return; + + $year = substr($row->openedDate, 0, 4); + $month = substr($row->openedDate, 5, 2); + + if($year == '0000') return; + + if(!isset($this->result[$year])) $this->result[$year] = array(); + if(!isset($this->result[$year][$month])) $this->result[$year][$month] = 0; + + $this->result[$year][$month] += 1; } public function getResult($options = array()) { - return $this->filterByOptions($this->result, $options); + $records = array(); + foreach($this->result as $year => $months) + { + foreach($months as $month => $value) + { + $records[] = array('year' => $year, 'month' => $month, 'value' => $value); + } + } + return $this->filterByOptions($records, $options); } -} \ No newline at end of file +} diff --git a/module/metric/calc/product/scale/count_of_daily_closed_bug_in_product.php b/module/metric/calc/product/scale/count_of_daily_closed_bug_in_product.php index 25fd5c1161..94ab8be0d9 100644 --- a/module/metric/calc/product/scale/count_of_daily_closed_bug_in_product.php +++ b/module/metric/calc/product/scale/count_of_daily_closed_bug_in_product.php @@ -32,7 +32,7 @@ class count_of_daily_closed_bug_in_product extends baseCalc $date = substr($row->closedDate, 0, 10); list($year, $month, $day) = explode('-', $date); - if($year == '0000' || $month == '00' || $day == '00') return; + if($year == '0000') return; if(!isset($this->result[$row->product])) $this->result[$row->product] = array(); if(!isset($this->result[$row->product][$year])) $this->result[$row->product][$year] = array(); diff --git a/module/metric/calc/product/scale/count_of_daily_created_bug_in_product.php b/module/metric/calc/product/scale/count_of_daily_created_bug_in_product.php index c3072dd284..2fc8e38565 100644 --- a/module/metric/calc/product/scale/count_of_daily_created_bug_in_product.php +++ b/module/metric/calc/product/scale/count_of_daily_created_bug_in_product.php @@ -32,7 +32,7 @@ class count_of_daily_created_bug_in_product extends baseCalc $date = substr($row->openedDate, 0, 10); list($year, $month, $day) = explode('-', $date); - if($year == '0000' && $month == '00' && $day == '00') return; + if($year == '0000') return; if(!isset($this->result[$row->product])) $this->result[$row->product] = array(); if(!isset($this->result[$row->product][$year])) $this->result[$row->product][$year] = array(); diff --git a/module/metric/calc/product/scale/count_of_daily_resolved_bug_in_product.php b/module/metric/calc/product/scale/count_of_daily_resolved_bug_in_product.php index 5563645588..ee57d39f86 100644 --- a/module/metric/calc/product/scale/count_of_daily_resolved_bug_in_product.php +++ b/module/metric/calc/product/scale/count_of_daily_resolved_bug_in_product.php @@ -32,7 +32,7 @@ class count_of_daily_resolved_bug_in_product extends baseCalc $date = substr($row->resolvedDate, 0, 10); list($year, $month, $day) = explode('-', $date); - if($year == '0000' && $month == '00' && $day == '00') return; + if($year == '0000') return; if(!isset($this->result[$row->product])) $this->result[$row->product] = array(); if(!isset($this->result[$row->product][$year])) $this->result[$row->product][$year] = array();