Class: GrafanaReporter::PanelImageQuery

Inherits:
AbstractQuery show all
Defined in:
lib/grafana_reporter/panel_image_query.rb

Overview

This class is used to create an image out of a Grafana::Panel.

Instance Attribute Summary

Attributes inherited from AbstractQuery

#dashboard, #datasource, #panel, #result, #variables

Instance Method Summary collapse

Methods inherited from AbstractQuery

#execute, #filter_columns, #format_columns, #format_table_output, #initialize, #replace_values, #timeout, #translate_date, #transpose

Constructor Details

This class inherits a constructor from GrafanaReporter::AbstractQuery

Instance Method Details

#post_processObject

Returns the body of the http query, which contains the raw image.



16
17
18
# File 'lib/grafana_reporter/panel_image_query.rb', line 16

def post_process
  @result = @result[:content].first
end

#pre_processObject

Sets the proper render variables.



7
8
9
10
11
12
13
# File 'lib/grafana_reporter/panel_image_query.rb', line 7

def pre_process
  # TODO: properly show error, if a (maybe a repeated template) panel can not be rendered
  # TODO: ensure that in case of timezones are specified, that they are also forwarded to the image renderer
  # rename "render-" variables
  @variables = @variables.each_with_object({}) { |(k, v), h| h[k.gsub(/^render-/, '')] = v }
  @datasource = Grafana::ImageRenderingDatasource.new(nil)
end

#raw_queryObject



21
22
23
# File 'lib/grafana_reporter/panel_image_query.rb', line 21

def raw_query
  { panel: @panel }
end