* @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_merged_mr extends baseCalc { public $dataset = 'getMRs'; public $fieldList = array('t1.status'); public $result = array('count' => 0, 'merged' => 0); public function calculate($row) { if($row->status == 'merged') $this->result['merged'] += 1; $this->result['count'] += 1; } public function getResult($options = array()) { $count = $this->result['count']; $merged = $this->result['merged']; $rate = $count == 0 ? 0 : round($merged / $count, 4); $records = array(array('value' => $rate)); return $this->filterByOptions($records, $options); } }