From 87d63bc60b7a4e124a8e1c0bd66adff89202001d Mon Sep 17 00:00:00 2001 From: liyang Date: Tue, 31 Dec 2024 08:36:57 +0800 Subject: [PATCH] + [task#125723] add count of host method. --- .../calc/system/scale/count_of_host.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/module/metric/calc/system/scale/count_of_host.php b/module/metric/calc/system/scale/count_of_host.php index 29ff269aa2..66a60e6518 100644 --- a/module/metric/calc/system/scale/count_of_host.php +++ b/module/metric/calc/system/scale/count_of_host.php @@ -18,3 +18,22 @@ * @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 count_of_host extends baseCalc +{ + public $dataset = 'getHosts'; + + public $fieldList = array('id'); + + public $result = 0; + + public function calculate($row) + { + $this->result += 1; + } + + public function getResult($options = array()) + { + $records = $this->getRecords(array('value')); + return $this->filterByOptions($records, $options); + } +}