Merge "Make it possible to sort on simple custom columns"
[ninja.git] / modules / reports / models / trends_graph.php
blob7c384ecded2f1fde6893b6a5f80f209e5f104619
1 <?php defined('SYSPATH') OR die('No direct access allowed.');
3 /**
4 * Model for generating trend graphs
5 */
6 class Trends_graph_Model extends Model
9 /**
10 * Fetch data to be used in the trends graph
12 * @param $data Data from get_sla_data
13 * @return $data_chart Formated data to fit trends graph
16 static public function format_graph_data ($data){
18 $data_chart = array();
19 $events = current($data);
21 // Group log entries by object type
22 foreach($data as $current_object => $events) {
23 foreach($events as $event) {
25 $output = '';
26 if (isset($event['output']))
27 $output = $event['output'];
29 $object_type = strpos($current_object, ';') !== false ? 'service' : 'host';
31 if(!isset($data_chart[$current_object])) {
32 $data_chart[$current_object] = array();
35 $data_chart[$current_object][] = array(
36 'duration' => $event['duration'],
37 'state' => $event['state'],
38 'object_type' => $object_type,
39 'output' => $output,
45 return $data_chart;