From 79ea0221650e2c56500145bdd4e1e61bf262e1b6 Mon Sep 17 00:00:00 2001 From: caoyanyi Date: Wed, 14 May 2025 08:56:28 +0800 Subject: [PATCH] + [task#142895,doing,0.4h] add finished test task rate. --- .../task/rate/rate_of_test_finished_task.php | 46 +++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 module/metric/calc/task/rate/rate_of_test_finished_task.php diff --git a/module/metric/calc/task/rate/rate_of_test_finished_task.php b/module/metric/calc/task/rate/rate_of_test_finished_task.php new file mode 100644 index 0000000000..0488b0e7d1 --- /dev/null +++ b/module/metric/calc/task/rate/rate_of_test_finished_task.php @@ -0,0 +1,46 @@ + + * @package + * @uses func + * @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 rate_of_test_finished_task extends baseCalc +{ + public $dataset = ''; + + public $fieldList = array(); + + public $result = array('finished' => 0, 'total' => 0); + + public function calculate($row) + { + if($row->type != 'test') return; + + $this->result['total'] += 1; + if($row->status == 'done' || $row->closedReason == 'done') $this->result['finished'] += 1; + } + + public function getResult($options = array()) + { + $total = $this->result['total']; + $finished = $this->result['finished']; + $rate = $total == 0 ? 0 : round($finished / $total, 4); + + $records = array(array('value' => $rate)); + return $this->filterByOptions($records, $options); + } +}