Class: Tiler::Widgets::MeterQuery
- Inherits:
-
Query::Base
- Object
- Query::Base
- Tiler::Widgets::MeterQuery
- Defined in:
- lib/tiler/widgets/meter.rb
Constant Summary collapse
- ALLOWED_AGG =
%w[avg sum max min last].freeze
Constants inherited from Query::Base
Instance Attribute Summary
Attributes inherited from Query::Base
Instance Method Summary collapse
Methods inherited from Query::Base
Constructor Details
This class inherits a constructor from Tiler::Query::Base
Instance Method Details
#call ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/tiler/widgets/meter.rb', line 9 def call col = config["value_column"] agg_raw = (config["aggregation"].presence || "last").to_s agg = ALLOWED_AGG.include?(agg_raw) ? agg_raw : "last" min = numeric(config["min"], 0) max = numeric(config["max"], nil) prefix = config["prefix"] suffix = config["suffix"] raw = col.present? ? aggregate(base_scope, col, agg) : nil clamped = clamp(raw, min, max) { value: clamped, min: min, max: max, prefix: prefix, suffix: suffix, value_column: col, color: sanitize_color(config["color"]) } end |