From 37b24c4bf2901a1877ceaae5cfea6d047690df7e Mon Sep 17 00:00:00 2001 From: liyang Date: Wed, 18 Dec 2024 10:01:00 +0800 Subject: [PATCH] * [task#134818] add rate of success deployment. --- .../system/qc/rate_of_success_deployment.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/module/metric/calc/system/qc/rate_of_success_deployment.php b/module/metric/calc/system/qc/rate_of_success_deployment.php index 934ab00bdb..ad2d6c0289 100644 --- a/module/metric/calc/system/qc/rate_of_success_deployment.php +++ b/module/metric/calc/system/qc/rate_of_success_deployment.php @@ -25,4 +25,20 @@ class rate_of_success_deployment extends baseCalc public $fieldList = array('status'); public $result = array('count' => 0, 'success' => 0); + + public function calculate($row) + { + if($row->status == 'success') $this->result['success'] += 1; + if(in_array($row->status, array('success', 'fail', 'doing'))) $this->result['count'] += 1; + } + + public function getResult($options = array()) + { + $count = $this->result['count']; + $success = $this->result['success']; + $rate = $count == 0 ? 0 : round($success / $count, 4); + + $records = array(array('value' => $rate)); + return $this->filterByOptions($records, $options); + } }