From 2a9ede995e871d8d98f90cd895bc0bedf658253c Mon Sep 17 00:00:00 2001 From: zhouxin Date: Thu, 8 Aug 2024 14:56:13 +0800 Subject: [PATCH] * [task#124866,done,0.5h] implement metric calc. --- .../count_of_case_expect_in_execution.php | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/module/metric/calc/execution/scale/count_of_case_expect_in_execution.php b/module/metric/calc/execution/scale/count_of_case_expect_in_execution.php index becd93b033..7826504270 100644 --- a/module/metric/calc/execution/scale/count_of_case_expect_in_execution.php +++ b/module/metric/calc/execution/scale/count_of_case_expect_in_execution.php @@ -18,3 +18,23 @@ * @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_case_expect_in_execution extends baseCalc +{ + public $dataset = 'getExecutionCasesSteps'; + + public $fieldList = array('t2.project as execution', 't1.expect'); + + public $result = array(); + + public function calculate($row) + { + if(empty($row->expect)) return; + if(!isset($this->result[$row->execution])) $this->result[$row->execution] = 0; + $this->result[$row->execution] += 1; + } + + public function getResult($options = array()) + { + return $this->filterByOptions($this->getRecords(array('execution', 'value')), $options); + } +}