* Finish task #99604.
This commit is contained in:
+23
-9
@@ -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,35 @@
|
||||
*/
|
||||
class count_of_daily_review_feedback_in_user extends baseCalc
|
||||
{
|
||||
public $dataset = null;
|
||||
public $dataset = 'getFeedbacks';
|
||||
|
||||
public $fieldList = array();
|
||||
|
||||
//public funtion getStatement($dao)
|
||||
//{
|
||||
//}
|
||||
public $fieldList = array('t1.reviewedBy', 't1.reviewedDate');
|
||||
|
||||
public function calculate($row)
|
||||
{
|
||||
$reviewedDate = $row->reviewedDate;
|
||||
$reviewedBy = $row->reviewedBy;
|
||||
|
||||
if(empty($reviewedDate) || empty($reviewedBy)) return false;
|
||||
|
||||
$year = substr($reviewedDate, 0, 4);
|
||||
if($year == '0000') return false;
|
||||
|
||||
$date = date("Y-m-d", strtotime($reviewedDate));
|
||||
list($year, $month, $day) = explode('-', $date);
|
||||
|
||||
if(!isset($this->result[$reviewedBy])) $this->result[$reviewedBy] = array();
|
||||
if(!isset($this->result[$reviewedBy][$year])) $this->result[$reviewedBy][$year] = array();
|
||||
if(!isset($this->result[$reviewedBy][$year][$month])) $this->result[$reviewedBy][$year][$month] = array();
|
||||
if(!isset($this->result[$reviewedBy][$year][$month][$day])) $this->result[$reviewedBy][$year][$month][$day] = 0;
|
||||
|
||||
$this->result[$reviewedBy][$year][$month][$day] += 1;
|
||||
|
||||
}
|
||||
|
||||
public function getResult($options = array())
|
||||
{
|
||||
$records = $this->getRecords(array('value'));
|
||||
$records = $this->getRecords(array('user', 'year', 'month', 'day', 'value'));
|
||||
return $this->filterByOptions($records, $options);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
include dirname(__FILE__, 7) . '/test/lib/init.php';
|
||||
include dirname(__FILE__, 4) . '/calc.class.php';
|
||||
|
||||
zdTable('product')->config('product_shadow', $useCommon = true, $levels = 4)->gen(10);
|
||||
zdTable('feedback')->config('feedback', $useCommon = true, $levels = 4)->gen(1000);
|
||||
|
||||
$metric = new metricTest();
|
||||
$calc = $metric->calcMetric(__FILE__);
|
||||
|
||||
/**
|
||||
|
||||
title=count_of_daily_review_feedback_in_user
|
||||
timeout=0
|
||||
cid=1
|
||||
|
||||
*/
|
||||
|
||||
r(count($calc->getResult())) && p('') && e('120'); // 测试分组数。
|
||||
|
||||
r(count($calc->getResult(array('user' => 'admin')))) && p('') && e('10'); // 测试用户admin
|
||||
r(count($calc->getResult(array('user' => 'user')))) && p('') && e('10'); // 测试用户user
|
||||
r(count($calc->getResult(array('user' => 'dev')))) && p('') && e('30'); // 测试用户dev
|
||||
r(count($calc->getResult(array('user' => 'pm')))) && p('') && e('20'); // 测试用户pm
|
||||
r($calc->getResult(array('user' => 'notexist'))) && p('') && e('0'); // 测试不存在的用户
|
||||
@@ -17,6 +17,12 @@ fields:
|
||||
range: "20110101 000000-20210101 230000:10D"
|
||||
type: timestamp
|
||||
format: YYYY-MM-DD hh:mm:ss
|
||||
- field: reviewedBy
|
||||
range: admin,user{5},test{4},dev{10},pm{8},po{2},closed{10},[]{10}
|
||||
- field: reviewedDate
|
||||
range: "20110101 000000-20210101 230000:10D"
|
||||
type: timestamp
|
||||
format: YYYY-MM-DD hh:mm:ss
|
||||
- field: deleted
|
||||
range: 0{1},1{1}
|
||||
...
|
||||
|
||||
Reference in New Issue
Block a user