* @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); } }