diff --git a/module/metric/calc/execution/hour/consumed_of_task_from_current_execution_bug_in_execution.php b/module/metric/calc/execution/hour/consumed_of_task_from_current_execution_bug_in_execution.php new file mode 100644 index 0000000000..1f7c350253 --- /dev/null +++ b/module/metric/calc/execution/hour/consumed_of_task_from_current_execution_bug_in_execution.php @@ -0,0 +1,53 @@ + + * @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 consumed_of_task_from_current_execution_bug_in_execution extends baseCalc +{ + public $result = array(); + + public $dataset = 'getTasksWithBuildInfo'; + + public $fieldList = array('t1.id as taskID', 't1.execution', 't1.consumed', 't2.openedBuild', 't5.id as currentBuild'); + + public function calculate($row) + { + if(!isset($this->result[$row->execution])) + { + $this->result[$row->execution] = array(); + $this->result[$row->execution]['consumed'] = 0; + $this->result[$row->execution]['taskList'] = array(); + } + + $openedBuildList = explode(',', $row->openedBuild); + if(!in_array($row->taskID, $this->result[$row->execution]['taskList']) && in_array($row->currentBuild, $openedBuildList)) + { + $this->result[$row->execution]['taskList'][] = $row->taskID; + $this->result[$row->execution]['consumed'] += $row->consumed; + } + } + + public function getResult($options = array()) + { + $records = array(); + foreach($this->result as $execution => $executionData) $records[] = array('execution' => $execution, 'value' => $executionData['consumed']); + + return $this->filterByOptions($records, $options); + } +}