* @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_fixed_bug extends baseCalc { public $dataset = 'getAllBugs'; public $fieldList = array('t1.status', 't1.resolution'); public $result = array('fixed' => 0, 'valid' => 0); public function calculate($row) { if($row->status == 'closed' and $row->resolution == 'fixed') $this->result['fixed'] += 1; if($row->status == 'active' or $row->resolution == 'fixed' or $row->resolution == 'postponed') $this->result['valid'] += 1; } public function getResult($options = array()) { $valid = $this->result['valid']; $fixed = $this->result['fixed']; $rate = $valid == 0 ? 0 : round($fixed / $valid, 4); $records = array(array('value' => $rate)); return $this->filterByOptions($records, $options); } }