Class: Temper

Inherits:
Object
  • Object
show all
Includes:
Graphs::AreaNotStackedChart, Mongoid::Attributes::Dynamic, Mongoid::Document, Mongoid::Timestamps
Defined in:
lib/app/models/temper.rb

Class Method Summary collapse

Class Method Details

.axes_defaultsObject



35
36
37
38
39
# File 'lib/app/models/temper.rb', line 35

def self.axes_defaults
  {
    :value_axis => {:title => 'Temperature in C'}
  }
end

.chart_data(options = {}) ⇒ Object



9
10
11
12
13
# File 'lib/app/models/temper.rb', line 9

def self.chart_data(options = {})
  charts = []
  charts << self.temper_chart(options)
  return charts
end

.graphsObject



41
42
43
44
45
46
47
48
49
50
# File 'lib/app/models/temper.rb', line 41

def self.graphs
  {
    :temperature => {
      :value_field => "Temperature",
      :hidden => false,
      :line_color => "#FF0000",
      :title => "Temperature"
    }
  }
end

.temper_chart(options) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/app/models/temper.rb', line 15

def self.temper_chart(options)
  chart = self.chart_structure({:title => "Temperature in [C]", :value_axis => { :title => "Temperature"}})
#    data = {
#               :value_axes => [
#                          { 
##			    :stack_type => 'regular',
#                          }
#                        ],
#             }


  #TODO - get fields from above DRY
  chart[:graph_data] = Temper.where(:timestamp.gte => options[:start]).
                              where(:timestamp.lt => options[:end]).
		where(:host_id => options[:host_id]).
		where(:plugin_id => options[:plugin_id]).
		order_by(timestamp: :asc)
  chart
end