* Finish task #99193.

This commit is contained in:
zhouxin
2023-07-31 16:29:19 +08:00
parent 1f8f28d0c8
commit af71b0ed6b
2 changed files with 32 additions and 9 deletions
@@ -14,7 +14,7 @@
* 收集方式:realtime
*
* @copyright Copyright 2009-2023 禅道软件(青岛)有限公司(ZenTao Software (Qingdao) Co., Ltd. www.zentao.net)
* @author qixinzhi <qixinzhi@easycorp.ltd>
* @author zhouixn <zhouixn@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)
@@ -22,21 +22,20 @@
*/
class count_of_doing_task_in_project extends baseCalc
{
public $dataset = null;
public $dataset = 'getTasks';
public $fieldList = array();
//public funtion getStatement($dao)
//{
//}
public $fieldList = array('t1.status', 't1.project');
public function calculate($row)
{
if($row->status != 'doing') return false;
if(!isset($this->result[$row->project])) $this->result[$row->project] = 0;
$this->result[$row->project] += 1;
}
public function getResult($options = array())
{
$records = $this->getRecords(array('value'));
$records = $this->getRecords(array('project', 'value'));
return $this->filterByOptions($records, $options);
}
}
}
@@ -0,0 +1,24 @@
#!/usr/bin/env php
<?php
include dirname(__FILE__, 7) . '/test/lib/init.php';
include dirname(__FILE__, 4) . '/calc.class.php';
zdTable('project')->config('project_status', $useCommon = true, $levels = 4)->gen(10);
zdTable('project')->config('execution', $useCommon = true, $levels = 4)->gen(20, false);
zdTable('task')->config('task', $useCommon = true, $levels = 4)->gen(1000);
$metric = new metricTest();
$calc = $metric->calcMetric(__FILE__);
/**
title=count_of_doing_task_in_project
timeout=0
cid=1
*/
r(count($calc->getResult())) && p('') && e('15'); // 测试分组数。
r($calc->getResult(array('project' => 12))) && p('0:value') && e('3'); // 测试项目12的进行中任务数
r($calc->getResult(array('project' => 24))) && p('0:value') && e('3'); // 测试项目24的进行中任务数
r($calc->getResult(array('project' => 36))) && p('0:value') && e('3'); // 测试项目36的进行中任务数