influxer 1.1.4 → 1.1.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 34d7516d9e613074dcc24cf1c401bf69af544fa8
4
- data.tar.gz: ea286c505a09b55058dc00fa05bebd1786c2de20
2
+ SHA256:
3
+ metadata.gz: 7088f24ca98f504a152e38aff5f5ccc895eef65f1916aa5986bc425d9ef2d532
4
+ data.tar.gz: 733e79c1bc8f7023fcb23032f519b7cfe5b7a61e373b1e7b213a821adcb29c43
5
5
  SHA512:
6
- metadata.gz: 96fbc0c09e0127c7be545ffab4e0108a9ea26c7d471678c74095d35ce55827103357ce584b371e86cdd82200ff0ea86a63fb1f4ff61890e6d841b59de1618d35
7
- data.tar.gz: 5e580bcbfebb8ca2d731cd658e81d7cd418dc90a4e423aac8ea47d5cb06ccdd409b4e938d6752be4f9b5955bbcede839a004c3ee77dd7fd103c01471a51e1a22
6
+ metadata.gz: 9f4217519c7c72281f1ed91fe9a22134a89be30f1e473f1ac06fc227599403d0b0d0938da7ebbbcc5f3e1c98f13916c560fb6692edbf59360d883be92766e65e
7
+ data.tar.gz: 9e88838a7c84d1ac73be7a583e4bebcc73c48ef22f3bdab12eab0adce32350bb694094c6833a2c38089524d7c88dc58fb8917ba35a74c9e353a7c2a809ab2bfc
@@ -4,7 +4,7 @@ matrix:
4
4
  include:
5
5
  - rvm: 2.2.1
6
6
  gemfile: gemfiles/rails32.gemfile
7
- - rvm: 2.3.0
7
+ - rvm: 2.4.3
8
8
  gemfile: gemfiles/rails42.gemfile
9
- - rvm: 2.3.1
9
+ - rvm: 2.5.0
10
10
  gemfile: gemfiles/rails5.gemfile
@@ -2,6 +2,10 @@
2
2
 
3
3
  ## master
4
4
 
5
+ ## 1.1.5
6
+
7
+ - [Fixes [#37](https://github.com/palkan/influxer/issues/37)] Timestamp ranges are quoted again. ([@jklimke][])
8
+
5
9
  ## 1.1.4
6
10
 
7
11
  - [Fixes [#35](https://github.com/palkan/influxer/issues/35)] Support time duration suffix and handle `'s'` and `'ms'` precisions. ([@palkan][])
@@ -109,3 +113,4 @@ end
109
113
 
110
114
  [@palkan]: https://github.com/palkan
111
115
  [@MPursche]: https://github.com/MPursche
116
+ [@jklimke]: https://github.com/jklimke
data/README.md CHANGED
@@ -3,48 +3,48 @@
3
3
 
4
4
  **NOTE**: Version 0.3.x supports InfluxDB >= 0.9.0. For InfluxDB 0.8.x use [version 0.2.5](https://github.com/palkan/influxer/tree/0.2.5).
5
5
 
6
- **NOTE**: Influxer is Rails 3, 4, 5 compatible!
6
+ **NOTE**: Influxer is Rails 4+ compatible!
7
7
 
8
8
  Influxer provides an ActiveRecord-style way to work with [InfluxDB](https://influxdb.com/) with many useful features, such as:
9
9
  - Familar query language (use `select`, `where`, `not`, `group` etc).
10
10
  - Support for Regex conditions: `where(page_id: /^home\/.*/) #=> select * ... where page_id=~/^home\/.*/`.
11
11
  - Special query methods for InfluxDB:
12
- - `time` - group by time (e.g. `Metrics.time(:hour) => # select * ... group by time(1h)`);
13
- - `past` - get only points for last hour/minute/whatever (e.g. `Metrics.past(:day) => # select * ... where time > now() - 1d`);
14
- - `since` - get only points since date (e.g. `Metrics.since(Time.utc(2014,12,31)) => # select * ... where time > 1419984000s`);
15
- - `merge` - merge series.
12
+ - `time` - group by time (e.g. `Metrics.time(:hour) => # select * ... group by time(1h)`);
13
+ - `past` - get only points for last hour/minute/whatever (e.g. `Metrics.past(:day) => # select * ... where time > now() - 1d`);
14
+ - `since` - get only points since date (e.g. `Metrics.since(Time.utc(2014,12,31)) => # select * ... where time > 1419984000s`);
15
+ - `merge` - merge series.
16
16
  - Scopes support
17
- ```ruby
18
- class Metrics < Influxer::Metrics
19
- default_scope -> { time(:hour).limit(1000) }
20
- tags :account_id
21
- attributes :value
22
- scope :unlimited, -> { limit(nil) }
23
- scope :by_account, -> (id) { where(account_id: id) if id.present? }
24
- end
25
-
26
- Metrics.by_account(1)
27
- # => select * from "metrics" group by time(1h) where account_id=1 limit 1000
28
-
29
- Metrics.unlimited.by_account(1).time(:week)
30
- # => select * from "metrics" group by time(1w) where account_id=1
31
-
32
- ```
17
+ ```ruby
18
+ class Metrics < Influxer::Metrics
19
+ default_scope -> { time(:hour).limit(1000) }
20
+ tags :account_id
21
+ attributes :value
22
+ scope :unlimited, -> { limit(nil) }
23
+ scope :by_account, -> (id) { where(account_id: id) if id.present? }
24
+ end
25
+
26
+ Metrics.by_account(1)
27
+ # => select * from "metrics" group by time(1h) where account_id=1 limit 1000
28
+
29
+ Metrics.unlimited.by_account(1).time(:week)
30
+ # => select * from "metrics" group by time(1w) where account_id=1
31
+
32
+ ```
33
33
  - Integrate with your model:
34
- ```ruby
35
- class UserVisits < Influxer::Metrics
36
- end
37
-
38
- class User < ActiveRecord::Base
39
- has_metrics :visits
40
- end
34
+ ```ruby
35
+ class UserVisits < Influxer::Metrics
36
+ end
37
+
38
+ class User < ActiveRecord::Base
39
+ has_metrics :visits
40
+ end
41
41
 
42
- user = User.find(1)
43
- user.visits.write(page_id: 'home')
44
- #=> < creates point {user_id: 1, page_id: 'home'} in 'user_visits' series >
42
+ user = User.find(1)
43
+ user.visits.write(page_id: 'home')
44
+ #=> < creates point {user_id: 1, page_id: 'home'} in 'user_visits' series >
45
45
 
46
- user.visits.where(page_id: 'home')
47
- #=> select * from user_visits where page_id='home'
48
- ```
46
+ user.visits.where(page_id: 'home')
47
+ #=> select * from user_visits where page_id='home'
48
+ ```
49
49
 
50
50
  Find more on [Wiki](https://github.com/palkan/influxer/wiki).
@@ -83,16 +83,16 @@ module Influxer
83
83
  if val.exclude_end?
84
84
  # begin...end range
85
85
  if negate
86
- "#{key} < #{quoted(val.begin)} or #{key} >= #{quoted(val.end)}"
86
+ "#{key} < #{quoted(val.begin, key)} or #{key} >= #{quoted(val.end, key)}"
87
87
  else
88
- "#{key} >= #{quoted(val.begin)} and #{key} < #{quoted(val.end)}"
88
+ "#{key} >= #{quoted(val.begin, key)} and #{key} < #{quoted(val.end, key)}"
89
89
  end
90
90
  else
91
91
  # begin..end range
92
92
  if negate
93
- "#{key} < #{quoted(val.begin)} or #{key} > #{quoted(val.end)}"
93
+ "#{key} < #{quoted(val.begin, key)} or #{key} > #{quoted(val.end, key)}"
94
94
  else
95
- "#{key} >= #{quoted(val.begin)} and #{key} <= #{quoted(val.end)}"
95
+ "#{key} >= #{quoted(val.begin, key)} and #{key} <= #{quoted(val.end, key)}"
96
96
  end
97
97
  end
98
98
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Influxer # :nodoc:
4
- VERSION = "1.1.4"
4
+ VERSION = "1.1.5"
5
5
  end
@@ -88,6 +88,14 @@ describe Influxer::Relation, :query do
88
88
  expect(rel.where(time: DateTime.new(2015)).to_sql).to eq "select * from \"dummy\" where (time = #{(DateTime.new(2015).to_time.to_r * 1_000_000_000).to_i})"
89
89
  end
90
90
 
91
+ it "handle date ranges" do
92
+ expect(rel.where(time: Date.new(2015)..Date.new(2016)).to_sql).to eq "select * from \"dummy\" where (time >= #{(Date.new(2015).to_time.to_r * 1_000_000_000).to_i} and time <= #{(Date.new(2016).to_time.to_r * 1_000_000_000).to_i})"
93
+ end
94
+
95
+ it "handle date time ranges" do
96
+ expect(rel.where(time: DateTime.new(2015)..DateTime.new(2016)).to_sql).to eq "select * from \"dummy\" where (time >= #{(DateTime.new(2015).to_time.to_r * 1_000_000_000).to_i} and time <= #{(DateTime.new(2016).to_time.to_r * 1_000_000_000).to_i})"
97
+ end
98
+
91
99
  it "handle inclusive ranges" do
92
100
  expect(rel.where(user_id: 1..4).to_sql).to eq "select * from \"dummy\" where (user_id >= 1 and user_id <= 4)"
93
101
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: influxer
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.4
4
+ version: 1.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vlad Dem
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-02-15 00:00:00.000000000 Z
11
+ date: 2018-02-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemodel
@@ -254,7 +254,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
254
254
  version: '0'
255
255
  requirements: []
256
256
  rubyforge_project:
257
- rubygems_version: 2.6.13
257
+ rubygems_version: 2.7.4
258
258
  signing_key:
259
259
  specification_version: 4
260
260
  summary: InfluxDB for Rails