Module: Prosperity::GraphHelper

Defined in:
app/helpers/prosperity/graph_helper.rb

Instance Method Summary collapse

Instance Method Details

#options_for_extractorsObject



3
4
5
# File 'app/helpers/prosperity/graph_helper.rb', line 3

def options_for_extractors
  Prosperity::Metric.extractors.keys.map(&:to_s).sort
end

#options_for_metric(metrics) ⇒ Object



7
8
9
# File 'app/helpers/prosperity/graph_helper.rb', line 7

def options_for_metric(metrics)
  metrics.map{|m| [m.title, m.id]}.sort_by(&:first)
end

#render_graph(graph, options = {}) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'app/helpers/prosperity/graph_helper.rb', line 11

def render_graph(graph, options = {})
  path_opts = options.slice(:start_time, :end_time, :option, :period)
  path = case graph
  when Graph
    graph_path(graph, path_opts)
  when Metric
    metric_path(graph, path_opts)
  else
    raise "Unsupported object #{graph.class}"
  end
  classes = [Array(options[:class]) + ['metric']].flatten.uniq
  render partial: "prosperity/graphs/render_graph", locals: {
    graph: graph,
    classes: classes,
    path: path,
  }
end