From 32a31ff623535149eb03ea8a3dc91434a54da449 Mon Sep 17 00:00:00 2001 From: caoyanyi Date: Tue, 13 May 2025 10:10:28 +0800 Subject: [PATCH] + [task#142891,doing,0.3h] add calc script for task status. --- .../task/scale/count_of_task_in_status.php | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 module/metric/calc/task/scale/count_of_task_in_status.php diff --git a/module/metric/calc/task/scale/count_of_task_in_status.php b/module/metric/calc/task/scale/count_of_task_in_status.php new file mode 100644 index 0000000000..2a61f2383e --- /dev/null +++ b/module/metric/calc/task/scale/count_of_task_in_status.php @@ -0,0 +1,47 @@ + + * @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 count_of_task_in_status extends baseCalc +{ + public $dataset = ''; + + public $fieldList = array(); + + public $result = array(); + + public function calculate($row) + { + if(!isset($this->result[$row->status])) $this->result[$row->status] = array(); + $this->result[$row->status][$row->id] = $row->id; + } + + public function getResult($options = array()) + { + foreach($this->result as $status => $tasks) + { + if(!is_array($tasks)) continue; + + $this->result[$status] = count($tasks); + } + + $records = $this->getRecords(array('status', 'value')); + return $this->filterByOptions($records, $options); + } +}