* Finish task#100392.

This commit is contained in:
qixinzhi
2023-08-14 09:13:35 +00:00
parent 474b100a02
commit 8de7ef641f
2 changed files with 65 additions and 0 deletions
@@ -0,0 +1,43 @@
<?php
/**
* 按项目统计的已关闭执行数。
* Count of closed execution in project.
*
* 范围:project
* 对象:execution
* 目的:scale
* 度量名称:按项目统计的已关闭执行数
* 单位:个
* 描述:按项目统计的已关闭执行数表示在项目中已关闭的执行项的数量,可以用来了解已关闭的执行数量。
* 定义:项目的执行个数求和␍;过滤已删除的执行␍;过滤已删除的项目;
* 度量库:
* 收集方式:realtime
*
* @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_closed_execution_in_project extends baseCalc
{
public $dataset = 'getExecutions';
public $fieldList = array('t1.project', 't1.status');
public function calculate($row)
{
$project = $row->project;
$status = $row->status;
if(!isset($this->result[$project])) $this->result[$project] = 0;
if($status == 'closed') $this->result[$project] += 1;
}
public function getResult($options = array())
{
$records = $this->getRecords(array('project', 'value'));
return $this->filterByOptions($records, $options);
}
}
@@ -0,0 +1,22 @@
#!/usr/bin/env php
<?php
include dirname(__FILE__, 7) . '/test/lib/init.php';
include dirname(__FILE__, 4) . '/calc.class.php';
zdTable('project')->config('project_close', $useCommon = true, $levels = 4)->gen(10);
zdTable('project')->config('execution', $useCommon = true, $levels = 4)->gen(1000, false);
$metric = new metricTest();
$calc = $metric->calcMetric(__FILE__);
/**
title=count_of_closed_execution_in_project
cid=1
pid=1
*/
r(count($calc->getResult())) && p('') && e('6'); // 测试分组数。
r($calc->getResult(array('project' => '10'))) && p('0:value') && e('20'); // 测试项目10。