influxer 1.0.1 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -1
- data/.rspec +2 -0
- data/.rubocop.yml +16 -1
- data/Changelog.md +24 -0
- data/Rakefile +4 -1
- data/influxer.gemspec +6 -3
- data/lib/influxer/client.rb +2 -0
- data/lib/influxer/config.rb +2 -0
- data/lib/influxer/engine.rb +2 -0
- data/lib/influxer/metrics/active_model3/model.rb +2 -0
- data/lib/influxer/metrics/metrics.rb +43 -11
- data/lib/influxer/metrics/relation/calculations.rb +2 -0
- data/lib/influxer/metrics/relation/time_query.rb +3 -1
- data/lib/influxer/metrics/relation/where_clause.rb +5 -4
- data/lib/influxer/metrics/relation.rb +16 -7
- data/lib/influxer/metrics/scoping/current_scope.rb +3 -1
- data/lib/influxer/metrics/scoping/default.rb +2 -0
- data/lib/influxer/metrics/scoping/named.rb +2 -0
- data/lib/influxer/metrics/scoping/old_current_scope.rb +2 -0
- data/lib/influxer/metrics/scoping.rb +2 -0
- data/lib/influxer/model.rb +2 -0
- data/lib/influxer/rails/client.rb +2 -0
- data/lib/influxer/version.rb +3 -1
- data/lib/influxer.rb +2 -0
- data/spec/cases/points_spec.rb +2 -0
- data/spec/cases/write_points_spec.rb +85 -0
- data/spec/client_spec.rb +2 -0
- data/spec/metrics/metrics_spec.rb +24 -4
- data/spec/metrics/relation_spec.rb +3 -1
- data/spec/metrics/scoping_spec.rb +3 -1
- data/spec/model/user_spec.rb +3 -1
- data/spec/spec_helper.rb +11 -0
- data/spec/support/metrics/action_metrics.rb +2 -0
- data/spec/support/metrics/custom_metrics.rb +2 -0
- data/spec/support/metrics/dummy_metrics.rb +2 -0
- data/spec/support/metrics/user_metrics.rb +2 -0
- data/spec/support/metrics/visits_metrics.rb +4 -0
- data/spec/support/shared_contexts/shared_query.rb +2 -0
- data/spec/support/user.rb +2 -0
- metadata +21 -6
- data/.hound.yml +0 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 47d8a3e1c19312557c99b513a074c2a1ca38fcb7
|
4
|
+
data.tar.gz: 9efb4e5a5ee1a3fa9f6aa7fef3d4f594266f67d1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1aca8b3b8005ece22d5b37bd93c4fb4bee7a8ea6ca37609141292fc055c08576c0cb7b405072392fdcbccdd72181093b42dfbe569355c20f566dacd31f47d573
|
7
|
+
data.tar.gz: 5c4bcb485f464da23f9868c2042856e8f99fb7ea3c0f5d71eff590a2b5604940e8c74f25294ff685aa6748f37cac2040e6bc2cfb2957f01eb5cc4b73f61aff50
|
data/.gitignore
CHANGED
data/.rspec
ADDED
data/.rubocop.yml
CHANGED
@@ -7,11 +7,22 @@ AllCops:
|
|
7
7
|
Exclude:
|
8
8
|
- 'bin/**/*'
|
9
9
|
- 'spec/dummy/**/*'
|
10
|
+
- 'vendor/**/*'
|
11
|
+
- 'gemfiles/vendor/**/*'
|
12
|
+
- Gemfile
|
13
|
+
- Rakefile
|
10
14
|
DisplayCopNames: true
|
11
15
|
StyleGuideCopsOnly: false
|
16
|
+
TargetRubyVersion: 2.3
|
12
17
|
|
13
18
|
Rails:
|
14
|
-
Enabled:
|
19
|
+
Enabled: false
|
20
|
+
|
21
|
+
Style/SymbolArray:
|
22
|
+
Enabled: false
|
23
|
+
|
24
|
+
Style/SafeNavigation:
|
25
|
+
Enabled: false
|
15
26
|
|
16
27
|
Style/AccessorMethodName:
|
17
28
|
Enabled: false
|
@@ -36,6 +47,10 @@ Style/BlockDelimiters:
|
|
36
47
|
Lint/AmbiguousRegexpLiteral:
|
37
48
|
Enabled: false
|
38
49
|
|
50
|
+
Metrics/BlockLength:
|
51
|
+
Exclude:
|
52
|
+
- 'spec/**/*.rb'
|
53
|
+
|
39
54
|
Metrics/MethodLength:
|
40
55
|
Exclude:
|
41
56
|
- 'spec/**/*.rb'
|
data/Changelog.md
CHANGED
@@ -1,5 +1,29 @@
|
|
1
1
|
# Change log
|
2
2
|
|
3
|
+
## 1.1.0
|
4
|
+
|
5
|
+
### Features
|
6
|
+
|
7
|
+
- Add ability to specify per-metrics retention-policy, precision and database
|
8
|
+
|
9
|
+
Now you can override default configuration for a specific metrics class:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
class CustomMetrics < Influxer::Metrics
|
13
|
+
set_database "custom_db"
|
14
|
+
set_retention_policy :yearly
|
15
|
+
set_precision "ms"
|
16
|
+
end
|
17
|
+
```
|
18
|
+
|
19
|
+
### Fixes
|
20
|
+
|
21
|
+
- [Fixes #30] Fix writing points with custom retention policy
|
22
|
+
|
23
|
+
### Misc
|
24
|
+
|
25
|
+
- Update Rubocop configuration and add Rubocop Rake task to defaults
|
26
|
+
|
3
27
|
## 1.0.1
|
4
28
|
|
5
29
|
- Fix missing `#delegate` in ActiveRecord 3.2
|
data/Rakefile
CHANGED
@@ -3,7 +3,10 @@ require "bundler/gem_tasks"
|
|
3
3
|
require 'rspec/core/rake_task'
|
4
4
|
RSpec::Core::RakeTask.new(:spec)
|
5
5
|
|
6
|
-
|
6
|
+
require "rubocop/rake_task"
|
7
|
+
RuboCop::RakeTask.new
|
8
|
+
|
9
|
+
task default: [:rubocop, :spec]
|
7
10
|
|
8
11
|
task :console do
|
9
12
|
sh 'pry -r ./lib/influxer.rb'
|
data/influxer.gemspec
CHANGED
@@ -1,4 +1,6 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
$LOAD_PATH.push File.expand_path("../lib", __FILE__)
|
2
4
|
|
3
5
|
require "influxer/version"
|
4
6
|
|
@@ -12,7 +14,7 @@ Gem::Specification.new do |s|
|
|
12
14
|
s.description = "InfluxDB the Rails way"
|
13
15
|
s.license = "MIT"
|
14
16
|
|
15
|
-
s.files = `git ls-files`.split(
|
17
|
+
s.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
|
16
18
|
s.require_paths = ["lib"]
|
17
19
|
|
18
20
|
s.add_dependency "activemodel", '>= 3.2.0'
|
@@ -26,5 +28,6 @@ Gem::Specification.new do |s|
|
|
26
28
|
s.add_development_dependency 'activerecord', '>= 3.2.0'
|
27
29
|
s.add_development_dependency 'pry-byebug'
|
28
30
|
s.add_development_dependency "rspec", ">= 3.1.0"
|
29
|
-
s.add_development_dependency "webmock", "~> 1
|
31
|
+
s.add_development_dependency "webmock", "~> 2.1"
|
32
|
+
s.add_development_dependency "rubocop", "~> 0.49"
|
30
33
|
end
|
data/lib/influxer/client.rb
CHANGED
data/lib/influxer/config.rb
CHANGED
data/lib/influxer/engine.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'influxer/metrics/relation'
|
2
4
|
require 'influxer/metrics/scoping'
|
3
5
|
require 'influxer/metrics/active_model3/model'
|
@@ -37,9 +39,8 @@ module Influxer
|
|
37
39
|
to: :all
|
38
40
|
)
|
39
41
|
|
40
|
-
attr_reader :series
|
42
|
+
attr_reader :series, :retention_policy, :database, :precision
|
41
43
|
attr_accessor :tag_names
|
42
|
-
attr_accessor :retention_policy
|
43
44
|
|
44
45
|
def attributes(*attrs)
|
45
46
|
attrs.each do |name|
|
@@ -68,10 +69,21 @@ module Influxer
|
|
68
69
|
subclass.tag_names = tag_names.nil? ? [] : tag_names.dup
|
69
70
|
end
|
70
71
|
|
72
|
+
# Use custom retention policy
|
71
73
|
def set_retention_policy(policy_name)
|
72
74
|
@retention_policy = policy_name
|
73
75
|
end
|
74
76
|
|
77
|
+
# Use custom database for this metrics
|
78
|
+
def set_database(database)
|
79
|
+
@database = database
|
80
|
+
end
|
81
|
+
|
82
|
+
# Use custom precision for this metrics
|
83
|
+
def set_precision(precision)
|
84
|
+
@precision = precision
|
85
|
+
end
|
86
|
+
|
75
87
|
# rubocop:disable Metrics/MethodLength
|
76
88
|
# rubocop:disable Metrics/AbcSize
|
77
89
|
def set_series(*args)
|
@@ -100,20 +112,24 @@ module Influxer
|
|
100
112
|
end
|
101
113
|
|
102
114
|
# rubocop:disable Metrics/MethodLength
|
103
|
-
|
115
|
+
# rubocop:disable Metrics/AbcSize
|
116
|
+
# rubocop:disable Metrics/CyclomaticComplexity
|
117
|
+
def quoted_series(val = @series, instance = nil, write: false)
|
104
118
|
case val
|
105
119
|
when Regexp
|
106
120
|
val.inspect
|
107
121
|
when Proc
|
108
|
-
quoted_series(val.call(instance))
|
122
|
+
quoted_series(val.call(instance), write: write)
|
109
123
|
when Array
|
110
124
|
if val.length > 1
|
111
|
-
"merge(#{val.map { |s| quoted_series(s) }.join(',')})"
|
125
|
+
"merge(#{val.map { |s| quoted_series(s, write: write) }.join(',')})"
|
112
126
|
else
|
113
|
-
quoted_series(val.first)
|
127
|
+
quoted_series(val.first, write: write)
|
114
128
|
end
|
115
129
|
else
|
116
|
-
|
130
|
+
# Only add retention policy when selecting points
|
131
|
+
# and not writing
|
132
|
+
if !write && retention_policy.present?
|
117
133
|
[quote(@retention_policy), quote(val)].join('.')
|
118
134
|
else
|
119
135
|
quote(val)
|
@@ -124,7 +140,8 @@ module Influxer
|
|
124
140
|
def quote(name)
|
125
141
|
'"' + name.to_s.gsub(/\"/) { '\"' } + '"'
|
126
142
|
end
|
127
|
-
|
143
|
+
# rubocop:enable Metrics/CyclomaticComplexity
|
144
|
+
# rubocop:enable Metrics/AbcSize
|
128
145
|
# rubocop:enable Metrics/MethodLength
|
129
146
|
end
|
130
147
|
|
@@ -153,7 +170,15 @@ module Influxer
|
|
153
170
|
end
|
154
171
|
|
155
172
|
def write_point
|
156
|
-
|
173
|
+
data = {
|
174
|
+
values: values,
|
175
|
+
tags: tags,
|
176
|
+
timestamp: parsed_timestamp
|
177
|
+
}
|
178
|
+
write_with_config(
|
179
|
+
unquote(series(write: true)),
|
180
|
+
data
|
181
|
+
)
|
157
182
|
@persisted = true
|
158
183
|
end
|
159
184
|
|
@@ -161,8 +186,8 @@ module Influxer
|
|
161
186
|
@persisted
|
162
187
|
end
|
163
188
|
|
164
|
-
def series
|
165
|
-
self.class.quoted_series(self.class.series, self)
|
189
|
+
def series(**options)
|
190
|
+
self.class.quoted_series(self.class.series, self, **options)
|
166
191
|
end
|
167
192
|
|
168
193
|
def client
|
@@ -189,6 +214,13 @@ module Influxer
|
|
189
214
|
|
190
215
|
private
|
191
216
|
|
217
|
+
def write_with_config(series, data)
|
218
|
+
client.write_point(series, data,
|
219
|
+
self.class.precision,
|
220
|
+
self.class.retention_policy,
|
221
|
+
self.class.database)
|
222
|
+
end
|
223
|
+
|
192
224
|
# rubocop:disable Metrics/MethodLength
|
193
225
|
# rubocop:disable Metrics/AbcSize
|
194
226
|
def parsed_timestamp
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Influxer
|
2
4
|
module TimeQuery #:nodoc:
|
3
5
|
TIME_ALIASES = {
|
@@ -11,7 +13,7 @@ module Influxer
|
|
11
13
|
month: '30d'
|
12
14
|
}.freeze
|
13
15
|
|
14
|
-
FILL_RESERVED = %i
|
16
|
+
FILL_RESERVED = %i[null previous none].freeze
|
15
17
|
|
16
18
|
# Add group value to relation. To be used instead of `group("time(...)").
|
17
19
|
# Accepts symbols and strings.
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Influxer
|
2
4
|
module WhereClause #:nodoc:
|
3
5
|
# accepts hash or strings conditions
|
@@ -14,10 +16,9 @@ module Influxer
|
|
14
16
|
protected
|
15
17
|
|
16
18
|
def build_where(args, hargs, negate)
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
when hargs.present?
|
19
|
+
if args.present? && args[0].is_a?(String)
|
20
|
+
where_values.concat(args.map { |str| "(#{str})" })
|
21
|
+
elsif hargs.present?
|
21
22
|
build_hash_where(hargs, negate)
|
22
23
|
else
|
23
24
|
false
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'active_support/core_ext/module/delegation'
|
2
4
|
require 'influxer/metrics/relation/time_query'
|
3
5
|
require 'influxer/metrics/relation/calculations'
|
@@ -13,17 +15,17 @@ module Influxer
|
|
13
15
|
|
14
16
|
attr_reader :values
|
15
17
|
|
16
|
-
SUPPORTED_EPOCH_FORMAT = %i
|
18
|
+
SUPPORTED_EPOCH_FORMAT = %i[h m s ms u ns].freeze
|
17
19
|
|
18
|
-
MULTI_VALUE_METHODS = %i
|
20
|
+
MULTI_VALUE_METHODS = %i[select where group order].freeze
|
19
21
|
|
20
|
-
MULTI_KEY_METHODS = %i
|
22
|
+
MULTI_KEY_METHODS = %i[fanout].freeze
|
21
23
|
|
22
|
-
SINGLE_VALUE_METHODS = %i
|
24
|
+
SINGLE_VALUE_METHODS = %i[fill time limit offset slimit soffset from normalized].freeze
|
23
25
|
|
24
|
-
MULTI_VALUE_SIMPLE_METHODS = %i
|
26
|
+
MULTI_VALUE_SIMPLE_METHODS = %i[select group].freeze
|
25
27
|
|
26
|
-
SINGLE_VALUE_SIMPLE_METHODS = %i
|
28
|
+
SINGLE_VALUE_SIMPLE_METHODS = %i[fill limit offset slimit soffset from].freeze
|
27
29
|
|
28
30
|
MULTI_VALUE_METHODS.each do |name|
|
29
31
|
class_eval <<-CODE, __FILE__, __LINE__ + 1
|
@@ -194,7 +196,9 @@ module Influxer
|
|
194
196
|
@instance.client.query(
|
195
197
|
to_sql,
|
196
198
|
denormalize: !normalized?,
|
197
|
-
epoch: @values[:epoch]
|
199
|
+
epoch: @values[:epoch]
|
200
|
+
)
|
201
|
+
)
|
198
202
|
@loaded = true
|
199
203
|
@records
|
200
204
|
end
|
@@ -288,5 +292,10 @@ module Influxer
|
|
288
292
|
return super unless @klass.respond_to?(method)
|
289
293
|
merge!(scoping { @klass.public_send(method, *args, &block) })
|
290
294
|
end
|
295
|
+
|
296
|
+
def respond_to_missing?(method, *args)
|
297
|
+
return true if @klass.respond_to?(method)
|
298
|
+
super
|
299
|
+
end
|
291
300
|
end
|
292
301
|
end
|
@@ -1,8 +1,10 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'active_support/per_thread_registry'
|
2
4
|
|
3
5
|
module Influxer
|
4
6
|
module Scoping
|
5
|
-
module CurrentScope
|
7
|
+
module CurrentScope # :nodoc:
|
6
8
|
# Clone of current_scope methods for newer versions of ActiveModel
|
7
9
|
def current_scope
|
8
10
|
ScopeRegistry.value_for(:current_scope, name)
|
data/lib/influxer/model.rb
CHANGED
data/lib/influxer/version.rb
CHANGED
data/lib/influxer.rb
CHANGED
data/spec/cases/points_spec.rb
CHANGED
@@ -0,0 +1,85 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe "Write points" do
|
6
|
+
before do
|
7
|
+
stub_request(:post, /write/)
|
8
|
+
.to_return(
|
9
|
+
status: 204
|
10
|
+
)
|
11
|
+
end
|
12
|
+
|
13
|
+
let(:metrics_class) do
|
14
|
+
Class.new(Influxer::Metrics) do
|
15
|
+
set_series :test
|
16
|
+
|
17
|
+
tags :user_id
|
18
|
+
|
19
|
+
attributes :val
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
let(:point) { 'test,user_id=1 val="2"' }
|
24
|
+
|
25
|
+
subject { metrics_class.write! user_id: 1, val: '2' }
|
26
|
+
|
27
|
+
it "calls HTTP with correct params" do
|
28
|
+
subject
|
29
|
+
expect(
|
30
|
+
a_request(:post, "http://localhost:8086/write")
|
31
|
+
.with(
|
32
|
+
query: { u: "root", p: "root", precision: 'ns', db: 'db' },
|
33
|
+
body: point
|
34
|
+
)
|
35
|
+
).to have_been_made
|
36
|
+
end
|
37
|
+
|
38
|
+
context "with retention policy" do
|
39
|
+
it "calls HTTP with correct params" do
|
40
|
+
metrics_class.set_retention_policy 'yearly'
|
41
|
+
|
42
|
+
subject
|
43
|
+
|
44
|
+
expect(
|
45
|
+
a_request(:post, "http://localhost:8086/write")
|
46
|
+
.with(
|
47
|
+
query: { u: "root", p: "root", precision: 'ns', db: 'db', rp: 'yearly' },
|
48
|
+
body: point
|
49
|
+
)
|
50
|
+
).to have_been_made
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
context "with custom db" do
|
55
|
+
it "calls HTTP with correct params" do
|
56
|
+
metrics_class.set_database 'another_db'
|
57
|
+
|
58
|
+
subject
|
59
|
+
|
60
|
+
expect(
|
61
|
+
a_request(:post, "http://localhost:8086/write")
|
62
|
+
.with(
|
63
|
+
query: { u: "root", p: "root", precision: 'ns', db: 'another_db' },
|
64
|
+
body: point
|
65
|
+
)
|
66
|
+
).to have_been_made
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
context "with custom db" do
|
71
|
+
it "calls HTTP with correct params" do
|
72
|
+
metrics_class.set_precision 'ms'
|
73
|
+
|
74
|
+
subject
|
75
|
+
|
76
|
+
expect(
|
77
|
+
a_request(:post, "http://localhost:8086/write")
|
78
|
+
.with(
|
79
|
+
query: { u: "root", p: "root", precision: 'ms', db: 'db' },
|
80
|
+
body: point
|
81
|
+
)
|
82
|
+
).to have_been_made
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
data/spec/client_spec.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
5
|
describe Influxer::Metrics, :query do
|
@@ -64,7 +66,7 @@ describe Influxer::Metrics, :query do
|
|
64
66
|
end
|
65
67
|
|
66
68
|
it "writes successfully" do
|
67
|
-
expect(client).to receive(:write_point).with("dummy", anything)
|
69
|
+
expect(client).to receive(:write_point).with("dummy", anything, nil, nil, nil)
|
68
70
|
expect(dummy_metrics.write).to be_truthy
|
69
71
|
expect(dummy_metrics.persisted?).to be_truthy
|
70
72
|
end
|
@@ -213,7 +215,13 @@ describe Influxer::Metrics, :query do
|
|
213
215
|
|
214
216
|
it "write data and return point" do
|
215
217
|
expect(client)
|
216
|
-
.to receive(:write_point).with(
|
218
|
+
.to receive(:write_point).with(
|
219
|
+
"dummies",
|
220
|
+
{ tags: { dummy_id: 2, host: 'test' }, values: { user_id: 1 }, timestamp: nil },
|
221
|
+
nil,
|
222
|
+
nil,
|
223
|
+
nil
|
224
|
+
)
|
217
225
|
|
218
226
|
point = dummy_metrics.write(user_id: 1, dummy_id: 2, host: 'test')
|
219
227
|
expect(point.persisted?).to be_truthy
|
@@ -226,7 +234,13 @@ describe Influxer::Metrics, :query do
|
|
226
234
|
expected_time = (timestamp_test.to_r * 1_000_000_000).to_i
|
227
235
|
|
228
236
|
expect(client)
|
229
|
-
.to receive(:write_point).with(
|
237
|
+
.to receive(:write_point).with(
|
238
|
+
"dummies",
|
239
|
+
{ tags: { dummy_id: 2, host: 'test' }, values: { user_id: 1 }, timestamp: expected_time },
|
240
|
+
nil,
|
241
|
+
nil,
|
242
|
+
nil
|
243
|
+
)
|
230
244
|
|
231
245
|
point = dummy_metrics.write(user_id: 1, dummy_id: 2, host: 'test', timestamp: timestamp_test)
|
232
246
|
expect(point.persisted?).to be_truthy
|
@@ -240,7 +254,13 @@ describe Influxer::Metrics, :query do
|
|
240
254
|
timestamp_test = base_time.to_s
|
241
255
|
|
242
256
|
expect(client)
|
243
|
-
.to receive(:write_point).with(
|
257
|
+
.to receive(:write_point).with(
|
258
|
+
"dummies",
|
259
|
+
{ tags: { dummy_id: 2, host: 'test' }, values: { user_id: 1 }, timestamp: (base_time.to_i * 1_000_000_000).to_i },
|
260
|
+
nil,
|
261
|
+
nil,
|
262
|
+
nil
|
263
|
+
)
|
244
264
|
|
245
265
|
point = dummy_metrics.write(user_id: 1, dummy_id: 2, host: 'test', timestamp: timestamp_test)
|
246
266
|
expect(point.persisted?).to be_truthy
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
5
|
describe Influxer::Relation, :query do
|
@@ -196,7 +198,7 @@ describe Influxer::Relation, :query do
|
|
196
198
|
expect(rel.time("4d").to_sql).to eq "select * from \"dummy\" group by time(4d)"
|
197
199
|
end
|
198
200
|
|
199
|
-
%w
|
201
|
+
%w[null previous none].each do |val|
|
200
202
|
it "group by time with string value and fill #{val}" do
|
201
203
|
expect(rel.time("4d", fill: val.to_sym).to_sql).to eq "select * from \"dummy\" group by time(4d) fill(#{val})"
|
202
204
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'spec_helper'
|
2
4
|
|
3
5
|
describe Influxer::Metrics, :query do
|
@@ -21,7 +23,7 @@ describe Influxer::Metrics, :query do
|
|
21
23
|
|
22
24
|
let(:doomy) do
|
23
25
|
Class.new(dappy) do
|
24
|
-
scope :by_user, ->
|
26
|
+
scope :by_user, ->(id) { where(user_id: id) if id.present? }
|
25
27
|
scope :hourly, -> { time(:hour) }
|
26
28
|
scope :daily, -> { time(:day) }
|
27
29
|
end
|
data/spec/model/user_spec.rb
CHANGED
data/spec/spec_helper.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
2
4
|
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
3
5
|
|
@@ -45,9 +47,18 @@ ActiveRecord::Base.establish_connection(adapter: 'sqlite3', database: ':memory:'
|
|
45
47
|
Dir["#{File.dirname(__FILE__)}/support/metrics/*.rb"].each { |f| require f }
|
46
48
|
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
|
47
49
|
|
50
|
+
WebMock.disable_net_connect!
|
51
|
+
|
48
52
|
RSpec.configure do |config|
|
49
53
|
config.mock_with :rspec
|
50
54
|
|
55
|
+
config.example_status_persistence_file_path = "tmp/rspec_examples.txt"
|
56
|
+
config.filter_run :focus
|
57
|
+
config.run_all_when_everything_filtered = true
|
58
|
+
|
59
|
+
config.order = :random
|
60
|
+
Kernel.srand config.seed
|
61
|
+
|
51
62
|
config.after(:each) { Influxer.reset! }
|
52
63
|
config.after(:each) { Timecop.return }
|
53
64
|
end
|
data/spec/support/user.rb
CHANGED
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.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vlad Dem
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-07-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemodel
|
@@ -156,14 +156,28 @@ dependencies:
|
|
156
156
|
requirements:
|
157
157
|
- - "~>"
|
158
158
|
- !ruby/object:Gem::Version
|
159
|
-
version: 1
|
159
|
+
version: '2.1'
|
160
160
|
type: :development
|
161
161
|
prerelease: false
|
162
162
|
version_requirements: !ruby/object:Gem::Requirement
|
163
163
|
requirements:
|
164
164
|
- - "~>"
|
165
165
|
- !ruby/object:Gem::Version
|
166
|
-
version: 1
|
166
|
+
version: '2.1'
|
167
|
+
- !ruby/object:Gem::Dependency
|
168
|
+
name: rubocop
|
169
|
+
requirement: !ruby/object:Gem::Requirement
|
170
|
+
requirements:
|
171
|
+
- - "~>"
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
version: '0.49'
|
174
|
+
type: :development
|
175
|
+
prerelease: false
|
176
|
+
version_requirements: !ruby/object:Gem::Requirement
|
177
|
+
requirements:
|
178
|
+
- - "~>"
|
179
|
+
- !ruby/object:Gem::Version
|
180
|
+
version: '0.49'
|
167
181
|
description: InfluxDB the Rails way
|
168
182
|
email:
|
169
183
|
- dementiev.vm@gmail.com
|
@@ -172,7 +186,7 @@ extensions: []
|
|
172
186
|
extra_rdoc_files: []
|
173
187
|
files:
|
174
188
|
- ".gitignore"
|
175
|
-
- ".
|
189
|
+
- ".rspec"
|
176
190
|
- ".rubocop.yml"
|
177
191
|
- ".travis.yml"
|
178
192
|
- Changelog.md
|
@@ -203,6 +217,7 @@ files:
|
|
203
217
|
- lib/influxer/rails/client.rb
|
204
218
|
- lib/influxer/version.rb
|
205
219
|
- spec/cases/points_spec.rb
|
220
|
+
- spec/cases/write_points_spec.rb
|
206
221
|
- spec/client_spec.rb
|
207
222
|
- spec/fixtures/empty_result.json
|
208
223
|
- spec/fixtures/single_series.json
|
@@ -238,7 +253,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
238
253
|
version: '0'
|
239
254
|
requirements: []
|
240
255
|
rubyforge_project:
|
241
|
-
rubygems_version: 2.6.
|
256
|
+
rubygems_version: 2.6.11
|
242
257
|
signing_key:
|
243
258
|
specification_version: 4
|
244
259
|
summary: InfluxDB for Rails
|