Module: Influxer::TimeQuery
- Included in:
- Relation
- Defined in:
- lib/influxer/metrics/relation/time_query.rb
Overview
:nodoc:
Constant Summary collapse
- TIME_ALIASES =
{ hour: '1h', minute: '1m', second: '1s', ms: '1ms', u: '1u', week: '1w', day: '1d', month: '30d' }.freeze
- FILL_RESERVED =
%i[null previous none].freeze
Instance Method Summary collapse
-
#past(val) ⇒ Object
Shortcut to define time interval with regard to current time.
-
#since(val) ⇒ Object
Shortcut to define start point of the time interval.
-
#time(val, options = {}) ⇒ Object
Add group value to relation.
Instance Method Details
#past(val) ⇒ Object
50 51 52 53 54 55 56 57 58 59 |
# File 'lib/influxer/metrics/relation/time_query.rb', line 50 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 |
#since(val) ⇒ Object
70 71 72 |
# File 'lib/influxer/metrics/relation/time_query.rb', line 70 def since(val) where("time > #{val.to_i}s") end |
#time(val, options = {}) ⇒ Object
28 29 30 31 32 33 34 35 36 37 |
# File 'lib/influxer/metrics/relation/time_query.rb', line 28 def time(val, = {}) @values[:time] = if val.is_a?(Symbol) TIME_ALIASES[val] || '1' + val.to_s else val end build_fill([:fill]) self end |