influx_orm 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +10 -5
- data/examples/model.rb +4 -1
- data/influx_orm.gemspec +1 -1
- data/lib/influx_orm/query.rb +13 -0
- data/lib/influx_orm/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ab702af682f13573f863cab0e3573683fa0c6e74
|
4
|
+
data.tar.gz: 46d0f0263b2e5997ea0d40b94d0eb48156328c99
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 139181ed1399d79a2730d8dfd789a3b19e01590f71ee2e8157d82fb71c90ee22b6dd59894ea909033f0617f1d64ef9489ae3113eb9920cb15704f9780da91db3
|
7
|
+
data.tar.gz: 40db7c74945f37a7151526b682e199a8139401708abe3ce817a289763ffee008f21965484b99657cf34eac16c285bb3c27b6d83ad4d44a49360cc0cc6e1322c4
|
data/README.md
CHANGED
@@ -26,7 +26,9 @@ Or install it yourself as:
|
|
26
26
|
|
27
27
|
```
|
28
28
|
InfluxORM.setup(
|
29
|
-
|
29
|
+
connection: { # For more, see InfluxDB::Client.new
|
30
|
+
database: 'xyz'
|
31
|
+
}
|
30
32
|
)
|
31
33
|
```
|
32
34
|
|
@@ -64,8 +66,8 @@ Memory.select('mean(*)') \
|
|
64
66
|
.where(host: 'A', time: {gte: Time.now - 10.day, lte: Time.now - 1.day}) \
|
65
67
|
.group_by('time(1m) fill(0)').result
|
66
68
|
|
67
|
-
Memory.where(host: 'B').limit(10).result
|
68
|
-
Memory.where("host = '
|
69
|
+
Memory.where(host: 'B').or(host: 'C').limit(10).result
|
70
|
+
Memory.where("host = 'A' AND time > now() - 1d").where(free: {lt: 1024}).result
|
69
71
|
|
70
72
|
query_obj = Memory.where(host: 'A').or(host: 'B')
|
71
73
|
Memory.where(region: 'US').or(query_obj) # select * from memorys where region = 'US' OR (host = 'A' OR host = 'B')
|
@@ -83,6 +85,9 @@ Support query methods
|
|
83
85
|
* `offset`: `offset(1)`
|
84
86
|
* `soffset`: `soffset(1)`
|
85
87
|
|
88
|
+
## Examples
|
89
|
+
|
90
|
+
See `/examples`
|
86
91
|
|
87
92
|
## Structure
|
88
93
|
|
@@ -95,7 +100,7 @@ Support query methods
|
|
95
100
|
`Model` forward query methods to `Query`, forward write to `@configuration.connection`
|
96
101
|
|
97
102
|
`Attributes` define and format the model attributes
|
98
|
-
|
103
|
+
|
99
104
|
|
100
105
|
## Development
|
101
106
|
|
@@ -105,7 +110,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
105
110
|
|
106
111
|
## Contributing
|
107
112
|
|
108
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
113
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/xiejiangzhi/influx_orm.
|
109
114
|
|
110
115
|
|
111
116
|
## License
|
data/examples/model.rb
CHANGED
@@ -13,7 +13,7 @@ class Book
|
|
13
13
|
|
14
14
|
influx_tag :book_id
|
15
15
|
influx_tag :category
|
16
|
-
influx_value :price
|
16
|
+
influx_value :price, :float
|
17
17
|
end
|
18
18
|
|
19
19
|
Book.insert(book_id: 1, category: 'A', price: 1.3)
|
@@ -27,3 +27,6 @@ Book.import([
|
|
27
27
|
puts Book.select(mean: '*').where(time: {gte: 'now() - 3d'}) \
|
28
28
|
.group_by('time(12h)', :category).fill(0).result
|
29
29
|
|
30
|
+
puts Book.where(category: 'A').where(time: {gte: 'now() - 1d'}).result
|
31
|
+
puts Book.where(category: 'A').or(category: 'B').result
|
32
|
+
|
data/influx_orm.gemspec
CHANGED
@@ -11,7 +11,7 @@ Gem::Specification.new do |spec|
|
|
11
11
|
|
12
12
|
spec.summary = %q{A simple InfluxDB ORM}
|
13
13
|
spec.description = %q{A simple InfluxDB ORM}
|
14
|
-
spec.homepage = ""
|
14
|
+
spec.homepage = "https://github.com/xiejiangzhi/influx_orm"
|
15
15
|
spec.license = "MIT"
|
16
16
|
|
17
17
|
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
data/lib/influx_orm/query.rb
CHANGED
@@ -143,6 +143,8 @@ module InfluxORM
|
|
143
143
|
|
144
144
|
def compare_cond_to_sql(name, hash)
|
145
145
|
hash.map do |k, v|
|
146
|
+
v = format_query_val(v) if name.to_sym == :time
|
147
|
+
|
146
148
|
case k.to_sym
|
147
149
|
when :gt then "#{name} > #{v}"
|
148
150
|
when :gte then "#{name} >= #{v}"
|
@@ -160,6 +162,17 @@ module InfluxORM
|
|
160
162
|
"#{k} #{v}"
|
161
163
|
end.join(', ')
|
162
164
|
end
|
165
|
+
|
166
|
+
def format_query_val(val)
|
167
|
+
case val
|
168
|
+
when Time, DateTime
|
169
|
+
"'#{val.iso8601}'"
|
170
|
+
when Date
|
171
|
+
"'#{val.to_time.iso8601}'"
|
172
|
+
else
|
173
|
+
val
|
174
|
+
end
|
175
|
+
end
|
163
176
|
end
|
164
177
|
end
|
165
178
|
|
data/lib/influx_orm/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: influx_orm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- jiangzhi.xie
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-06-
|
11
|
+
date: 2017-06-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: influxdb
|
@@ -127,7 +127,7 @@ files:
|
|
127
127
|
- lib/influx_orm/model.rb
|
128
128
|
- lib/influx_orm/query.rb
|
129
129
|
- lib/influx_orm/version.rb
|
130
|
-
homepage:
|
130
|
+
homepage: https://github.com/xiejiangzhi/influx_orm
|
131
131
|
licenses:
|
132
132
|
- MIT
|
133
133
|
metadata: {}
|
@@ -147,7 +147,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
147
147
|
version: '0'
|
148
148
|
requirements: []
|
149
149
|
rubyforge_project:
|
150
|
-
rubygems_version: 2.
|
150
|
+
rubygems_version: 2.4.5.2
|
151
151
|
signing_key:
|
152
152
|
specification_version: 4
|
153
153
|
summary: A simple InfluxDB ORM
|