Sha256: eba6cdfa34903b16617d9ee167634a8c867c4f7c861eddb17dba0be6216e3960
Contents?: true
Size: 868 Bytes
Versions: 2
Compression:
Stored size: 868 Bytes
Contents
# helpers for processing params and validating input module BatsdDash module ParamsHelper def parse_statistics Hash.new { |hash,key| hash[key] = [] }.tap do |stats| %w[ counters gauges timers ].each do |datatype| list = params[datatype] list = [list] unless Array === list list.reject! { |m| m.nil? || m.empty? } stats[datatype] = list unless list.empty? end end end def parse_time_range start, stop = params[:start], params[:stop] if start.nil? && stop.nil? now = Time.now.to_i # 1 hr range # TODO make this setting? [ now - 1800, now ] else [start.to_i, stop.to_i].tap do |range| if range[0] <= 0 || range[1] <= 0 || range[0] >= range[1] return nil end end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
batsd-dash-0.3.1 | lib/batsd-dash/params.rb |
batsd-dash-0.3.0 | lib/batsd-dash/params.rb |