public function load() { parent::load(); $this->view->rgs = $this->rgs; $model = new ResourceGroup(); $this->view->resource_groups = $model->getindex(); $service_type_model = new Service(); $this->view->service_info = $service_type_model->getindex(); /////////////////////////////////////////////////////////////////////// // Load graph inforamtion $this->view->services = array(); foreach ($this->rgs as $rgid => $rg) { foreach ($rg as $rid => $resource) { //pull A&R history $model = new ServiceAR(); $params["start_time"] = $this->view->start_time; $params["end_time"] = $this->view->end_time; $params["resource_ids"] = array($rid); $this->view->services[$rid] = $model->getgroupby("service_id", $params); } } $this->setpagetitle(self::default_title()); }
public function load() { parent::load(); $this->view->rgs = $this->rgs; $model = new ResourceGroup(); $this->view->resource_groups = $model->getindex(); $service_type_model = new Service(); $this->view->services = $service_type_model->getindex(); //load AR history $model = new ServiceAR(); $params = array(); $params["start_time"] = $this->view->start_time; $params["end_time"] = $this->view->end_time; //get list of resource ids that we are interested in $resource_ids = array(); foreach ($this->rgs as $rgid => $rg) { foreach ($rg as $rid => $resource) { $resource_ids[] = $rid; } } //group by resource/service_id $ar_resource_service = array(); if (!empty($resource_ids)) { $params["resource_ids"] = $resource_ids; $ar = $model->get($params); foreach ($ar as $a) { $r_id = (int) $a->resource_id; if (!isset($ar_resource_service[$r_id])) { $ar_resource_service[$r_id] = array(); } $service_id = (int) $a->service_id; if (!isset($ar_resource_service[$r_id][$service_id])) { $ar_resource_service[$r_id][$service_id] = array(); } $ar_resource_service[$r_id][$service_id][] = $a; } } $data = array(); foreach ($ar_resource_service as $rid => $resource) { //filter by resource_id if (!in_array($rid, $resource_ids)) { continue; } $data[$rid] = array(); foreach ($resource as $service_id => $service) { $count = 0; $a_total = 0; $r_total = 0; foreach ($service as $rec) { $count++; $a_total += (double) $rec->availability; $r_total += (double) $rec->reliability; } //store data if ($count != 0) { $data[$rid][$service_id] = array("availability" => $a_total / $count, "reliability" => $r_total / $count); } } } //sort data if (isset($_REQUEST["sort"])) { $dirty_sort = $_REQUEST["sort"]; switch ($dirty_sort) { case "resource_name": break; case "a": uasort($data, "cmp_availability"); break; case "r": uasort($data, "cmp_reliability"); break; } } $this->view->data = $data; $this->setpagetitle(self::default_title()); }