From c3e51e9cfbe6d7fd613628cfd4e79b16b80b3da3 Mon Sep 17 00:00:00 2001 From: zhouxin Date: Tue, 1 Aug 2023 16:45:20 +0800 Subject: [PATCH] * Finish task #99190. --- ...ect.php.tmp => left_period_of_project.php} | 22 +++++++++++-------- .../project/time/left_period_of_project.php | 19 ++++++++++++++++ 2 files changed, 32 insertions(+), 9 deletions(-) rename module/metric/calc/project/time/{left_period_of_project.php.tmp => left_period_of_project.php} (75%) create mode 100644 module/metric/test/calc/project/time/left_period_of_project.php diff --git a/module/metric/calc/project/time/left_period_of_project.php.tmp b/module/metric/calc/project/time/left_period_of_project.php similarity index 75% rename from module/metric/calc/project/time/left_period_of_project.php.tmp rename to module/metric/calc/project/time/left_period_of_project.php index 7ba954f0aa..cb8b5595c1 100644 --- a/module/metric/calc/project/time/left_period_of_project.php.tmp +++ b/module/metric/calc/project/time/left_period_of_project.php @@ -14,7 +14,7 @@ * 收集方式: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) @@ -22,21 +22,25 @@ */ class left_period_of_project extends baseCalc { - public $dataset = null; + public $dataset = 'getAllProjects'; - public $fieldList = array(); - - //public funtion getStatement($dao) - //{ - //} + public $fieldList = array('id', 'status', 'end'); public function calculate($row) { + if($row->status == 'closed') + { + $this->result[$row->id] = 0; + } + else + { + $this->result[$row->id] = $row->end - date('Y-m-d'); + } } public function getResult($options = array()) { - $records = $this->getRecords(array('value')); + $records = $this->getRecords(array('project', 'value')); return $this->filterByOptions($records, $options); } -} \ No newline at end of file +} diff --git a/module/metric/test/calc/project/time/left_period_of_project.php b/module/metric/test/calc/project/time/left_period_of_project.php new file mode 100644 index 0000000000..966aac6589 --- /dev/null +++ b/module/metric/test/calc/project/time/left_period_of_project.php @@ -0,0 +1,19 @@ +#!/usr/bin/env php +config('project_status', $useCommon = true, $levels = 4)->gen(100); + +$metric = new metricTest(); +$calc = $metric->calcMetric(__FILE__); + +/** + +title=left_period_of_project +cid=1 +pid=1 + +*/ + +r(count($calc->getResult())) && p('') && e('100'); // 测试分组数。