influxer 1.1.4 → 1.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/.travis.yml +2 -2
- data/Changelog.md +5 -0
- data/README.md +34 -34
- data/lib/influxer/metrics/relation/where_clause.rb +4 -4
- data/lib/influxer/version.rb +1 -1
- data/spec/metrics/relation_spec.rb +8 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 7088f24ca98f504a152e38aff5f5ccc895eef65f1916aa5986bc425d9ef2d532
|
4
|
+
data.tar.gz: 733e79c1bc8f7023fcb23032f519b7cfe5b7a61e373b1e7b213a821adcb29c43
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9f4217519c7c72281f1ed91fe9a22134a89be30f1e473f1ac06fc227599403d0b0d0938da7ebbbcc5f3e1c98f13916c560fb6692edbf59360d883be92766e65e
|
7
|
+
data.tar.gz: 9e88838a7c84d1ac73be7a583e4bebcc73c48ef22f3bdab12eab0adce32350bb694094c6833a2c38089524d7c88dc58fb8917ba35a74c9e353a7c2a809ab2bfc
|
data/.travis.yml
CHANGED
data/Changelog.md
CHANGED
@@ -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
|
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
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
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
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
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
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
34
|
+
```ruby
|
35
|
+
class UserVisits < Influxer::Metrics
|
36
|
+
end
|
37
|
+
|
38
|
+
class User < ActiveRecord::Base
|
39
|
+
has_metrics :visits
|
40
|
+
end
|
41
41
|
|
42
|
-
|
43
|
-
|
44
|
-
|
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
|
-
|
47
|
-
|
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
|
data/lib/influxer/version.rb
CHANGED
@@ -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
|
+
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-
|
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.
|
257
|
+
rubygems_version: 2.7.4
|
258
258
|
signing_key:
|
259
259
|
specification_version: 4
|
260
260
|
summary: InfluxDB for Rails
|