* Finish task #99218.
This commit is contained in:
@@ -14,7 +14,7 @@
|
||||
* 收集方式:realtime
|
||||
*
|
||||
* @copyright Copyright 2009-2023 禅道软件(青岛)有限公司(ZenTao Software (Qingdao) Co., Ltd. www.zentao.net)
|
||||
* @author qixinzhi <qixinzhi@easycorp.ltd>
|
||||
* @author zhouxin <zhouxin@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,29 @@
|
||||
*/
|
||||
class count_of_daily_finished_task_in_execution extends baseCalc
|
||||
{
|
||||
public $dataset = null;
|
||||
public $dataset = 'getTasks';
|
||||
|
||||
public $fieldList = array();
|
||||
|
||||
//public funtion getStatement($dao)
|
||||
//{
|
||||
//}
|
||||
public $fieldList = array('t1.status', 't1.finishedDate', 't1.execution');
|
||||
|
||||
public function calculate($row)
|
||||
{
|
||||
if($row->status != 'done' || empty($row->finishedDate)) return false;
|
||||
|
||||
$date = substr($row->finishedDate, 0, 10);
|
||||
list($year, $month, $day) = explode('-', $date);
|
||||
if($year == '0000') return false;
|
||||
|
||||
if(!isset($this->result[$row->execution])) $this->result[$row->execution] = array();
|
||||
if(!isset($this->result[$row->execution][$year])) $this->result[$row->execution][$year] = array();
|
||||
if(!isset($this->result[$row->execution][$year][$month])) $this->result[$row->execution][$year][$month] = array();
|
||||
if(!isset($this->result[$row->execution][$year][$month][$day])) $this->result[$row->execution][$year][$month][$day] = 0;
|
||||
|
||||
$this->result[$row->execution][$year][$month][$day] ++;
|
||||
}
|
||||
|
||||
public function getResult($options = array())
|
||||
{
|
||||
$records = $this->getRecords(array('value'));
|
||||
$records = $this->getRecords(array('execution', 'year', 'month', 'day', 'value'));
|
||||
return $this->filterByOptions($records, $options);
|
||||
}
|
||||
}
|
||||
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
#!/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_daily_finished_task_in_execution
|
||||
timeout=0
|
||||
cid=1
|
||||
|
||||
- 测试分组数。 @44
|
||||
|
||||
- 测试执行11的分组数第0条的value属性 @1
|
||||
|
||||
- 测试执行12的分组数第0条的value属性 @1
|
||||
|
||||
- 测试执行13的分组数第0条的value属性 @1
|
||||
|
||||
- 测试执行20的分组数第0条的value属性 @1
|
||||
|
||||
- 测试执行11在2010年1月21日的完成任务数第0条的value属性 @1
|
||||
|
||||
- 测试执行11在2016年8月17日的完成任务数第0条的value属性 @1
|
||||
|
||||
- 测试执行11在2012年3月11日的完成任务数第0条的value属性 @1
|
||||
|
||||
*/
|
||||
|
||||
r(count($calc->getResult())) && p('') && e('44'); // 测试分组数。
|
||||
|
||||
r($calc->getResult(count(array('execution' => 11)))) && p('0:value') && e('1'); // 测试执行11的分组数
|
||||
r($calc->getResult(count(array('execution' => 12)))) && p('0:value') && e('1'); // 测试执行12的分组数
|
||||
r($calc->getResult(count(array('execution' => 13)))) && p('0:value') && e('1'); // 测试执行13的分组数
|
||||
r($calc->getResult(count(array('execution' => 20)))) && p('0:value') && e('1'); // 测试执行20的分组数
|
||||
|
||||
r($calc->getResult(array('execution' => 11, 'year' => '2010', 'month' => '01', 'day' => '21'))) && p('0:value') && e('1'); // 测试执行11在2010年1月21日的完成任务数
|
||||
r($calc->getResult(array('execution' => 11, 'year' => '2016', 'month' => '08', 'day' => '17'))) && p('0:value') && e('1'); // 测试执行11在2016年8月17日的完成任务数
|
||||
r($calc->getResult(array('execution' => 11, 'year' => '2012', 'month' => '03', 'day' => '11'))) && p('0:value') && e('1'); // 测试执行11在2012年3月11日的完成任务数
|
||||
Reference in New Issue
Block a user