Method: Influxer::TimeQuery#past

Defined in:
lib/influxer/metrics/relation/time_query.rb

#past(val) ⇒ Object

Shortcut to define time interval with regard to current time. Accepts symbols and numbers.

Metrics.past(:hour)
# select * from metrics where time > now() - 1h

Metrics.past(:d)
# select * from metrics where time > now() - 1d

Metrics.past(2.days)
# select * from metrics where time > now() - 172800s


51
52
53
54
55
56
57
58
59
60
# File 'lib/influxer/metrics/relation/time_query.rb', line 51

def past(val)
  case val
  when Symbol
    where("time > now() - #{TIME_ALIASES[val] || ('1' + val.to_s)}")
  when String
    where("time > now() - #{val}")
  else
    where("time > now() - #{val.to_i}s")
  end
end