From 562db384dbf977dcac71c1d2b8b387f8ddef332c Mon Sep 17 00:00:00 2001 From: zhouxin Date: Tue, 25 Jul 2023 15:11:16 +0800 Subject: [PATCH] * Add metric: count_of_line. --- ...ount_of_line.php.tmp => count_of_line.php} | 20 +++++++++---------- module/metric/dataset.php | 19 ++++++++++++++++++ 2 files changed, 28 insertions(+), 11 deletions(-) rename module/metric/calc/global/scale/{count_of_line.php.tmp => count_of_line.php} (72%) diff --git a/module/metric/calc/global/scale/count_of_line.php.tmp b/module/metric/calc/global/scale/count_of_line.php similarity index 72% rename from module/metric/calc/global/scale/count_of_line.php.tmp rename to module/metric/calc/global/scale/count_of_line.php index 23fa1656ab..dd81ae184c 100644 --- a/module/metric/calc/global/scale/count_of_line.php.tmp +++ b/module/metric/calc/global/scale/count_of_line.php @@ -10,12 +10,12 @@ * 单位:个 * 描述:按全局统计的产品线总数表示整个组织中的产品线数量。此度量项反映了组织的产品线广度,可以用于评估组织的产品组合策略和业务发展方向。 * 定义:所有产品线的个数求和 -过滤已删除的产品线 + * 过滤已删除的产品线 * 度量库: * 收集方式: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) @@ -23,20 +23,18 @@ */ class count_of_line extends baseCalc { - public $dataset = null; + public $dataset = 'getLines'; - public $fieldList = array(); + public $fieldList = array('t1.id'); - //public funtion getStatement($dao) - //{ - //} - - public function calculate($data) + public function calculate($row) { + $this->result ++; } public function getResult($options = array()) { - return $this->filterByOptions($this->result, $options); + $records = array(array('value' => $this->result)); + return $this->filterByOptions($records, $options); } -} \ No newline at end of file +} diff --git a/module/metric/dataset.php b/module/metric/dataset.php index fe8a6b5584..053bcec431 100644 --- a/module/metric/dataset.php +++ b/module/metric/dataset.php @@ -317,4 +317,23 @@ class dataset ->andWhere('t3.deleted')->eq(0) ->query(); } + + /** + * 获取产品线数据。 + * Get product lines. + * + * @param string $fieldList + * @access public + * @return PDOStatement + */ + public function getLines($fieldList) + { + return $this->dao->select($fieldList)->from(TABLE_MODULE)->alias('t1') + ->leftJoin(TABLE_PROJECT)->alias('t2')->on('t1.root=t2.id') + ->where('t1.deleted')->eq(0) + ->andWhere('t2.deleted')->eq(0) + ->andWhere('t1.type')->eq('line') + ->andWhere('t2.type')->eq('program') + ->query(); + } }