influxer 1.1.6 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +34 -58
- data/.travis.yml +6 -1
- data/Changelog.md +6 -2
- data/Gemfile +5 -2
- data/MIT-LICENSE +1 -1
- data/README.md +21 -21
- data/Rakefile +4 -2
- data/bin/console +8 -0
- data/gemfiles/rails32.gemfile +1 -1
- data/gemfiles/rails42.gemfile +1 -1
- data/gemfiles/rails5.gemfile +2 -2
- data/gemfiles/rails6.gemfile +7 -0
- data/influxer.gemspec +16 -9
- data/lib/influxer.rb +10 -9
- data/lib/influxer/client.rb +1 -1
- data/lib/influxer/config.rb +3 -3
- data/lib/influxer/engine.rb +1 -1
- data/lib/influxer/metrics/active_model3/model.rb +2 -4
- data/lib/influxer/metrics/metrics.rb +8 -8
- data/lib/influxer/metrics/quoting/timestamp.rb +13 -13
- data/lib/influxer/metrics/relation.rb +17 -13
- data/lib/influxer/metrics/relation/calculations.rb +1 -1
- data/lib/influxer/metrics/relation/time_query.rb +15 -14
- data/lib/influxer/metrics/relation/where_clause.rb +6 -4
- data/lib/influxer/metrics/scoping.rb +4 -4
- data/lib/influxer/metrics/scoping/current_scope.rb +2 -1
- data/lib/influxer/metrics/scoping/default.rb +1 -1
- data/lib/influxer/metrics/scoping/named.rb +2 -1
- data/lib/influxer/model.rb +4 -9
- data/lib/influxer/rails/client.rb +1 -1
- data/lib/influxer/version.rb +1 -1
- data/spec/cases/points_spec.rb +4 -4
- data/spec/cases/write_points_spec.rb +9 -9
- data/spec/client_spec.rb +4 -4
- data/spec/metrics/metrics_spec.rb +16 -16
- data/spec/metrics/relation_spec.rb +11 -11
- data/spec/metrics/scoping_spec.rb +2 -2
- data/spec/model/user_spec.rb +2 -2
- data/spec/spec_helper.rb +13 -14
- data/spec/support/shared_contexts/shared_precision.rb +1 -1
- metadata +27 -63
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 020023da263e0ad14394211eaab3b6388359a2ebd8de084182eeddca8b4f7569
|
4
|
+
data.tar.gz: 4648019961ea24ff2132d73b7975a801f0be0270380ba003223166191c4d924d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3215b0bc249ad3e927f9f77dafb417c29c915c6b32f8f2342c6507b4d165f2a46b9aae82fe815ac374a2785f46c19020b6dd2688e8a208a79cc2a7e7060eb42c
|
7
|
+
data.tar.gz: 70b27b50e9e98dcebde9b9ef4f16e1899c3f056770f31ece57af1c4c092a08ffa2484a4343e9c87795ffeca6b79553f9ab78a8dd431d40a75f0a2a808cf605b4
|
data/.rubocop.yml
CHANGED
@@ -1,81 +1,57 @@
|
|
1
|
+
require:
|
2
|
+
- standard/cop/semantic_blocks
|
3
|
+
- rubocop-md
|
4
|
+
|
5
|
+
inherit_gem:
|
6
|
+
standard: config/base.yml
|
7
|
+
|
1
8
|
AllCops:
|
2
|
-
# Include gemspec and Rakefile
|
3
|
-
Include:
|
4
|
-
- 'lib/**/*.rb'
|
5
|
-
- 'lib/**/*.rake'
|
6
|
-
- 'spec/**/*.rb'
|
7
9
|
Exclude:
|
8
|
-
- 'bin
|
9
|
-
- '
|
10
|
+
- 'bin/*'
|
11
|
+
- 'tmp/**/*'
|
12
|
+
- 'docs/**/*'
|
13
|
+
- 'Gemfile'
|
10
14
|
- 'vendor/**/*'
|
11
|
-
- 'gemfiles
|
12
|
-
- '**/*.gemfile'
|
13
|
-
- Gemfile
|
14
|
-
- Rakefile
|
15
|
+
- 'gemfiles/**/*'
|
15
16
|
DisplayCopNames: true
|
16
|
-
|
17
|
-
TargetRubyVersion: 2.3
|
18
|
-
|
19
|
-
Rails:
|
20
|
-
Enabled: false
|
17
|
+
TargetRubyVersion: 2.4
|
21
18
|
|
22
|
-
|
19
|
+
Standard/SemanticBlocks:
|
23
20
|
Enabled: false
|
24
21
|
|
25
|
-
Style/
|
26
|
-
Enabled:
|
27
|
-
|
28
|
-
Style/SafeNavigation:
|
29
|
-
Enabled: false
|
22
|
+
Style/FrozenStringLiteralComment:
|
23
|
+
Enabled: true
|
30
24
|
|
31
25
|
Naming/AccessorMethodName:
|
32
26
|
Enabled: false
|
33
27
|
|
34
|
-
Style/
|
35
|
-
|
28
|
+
Style/TrailingCommaInArrayLiteral:
|
29
|
+
EnforcedStyleForMultiline: no_comma
|
36
30
|
|
37
|
-
Style/
|
38
|
-
|
39
|
-
- 'spec/**/*.rb'
|
31
|
+
Style/TrailingCommaInHashLiteral:
|
32
|
+
EnforcedStyleForMultiline: no_comma
|
40
33
|
|
41
|
-
|
42
|
-
|
34
|
+
Layout/AlignParameters:
|
35
|
+
EnforcedStyle: with_first_parameter
|
43
36
|
|
44
|
-
|
37
|
+
Lint/Void:
|
45
38
|
Exclude:
|
46
|
-
- '
|
47
|
-
|
48
|
-
Naming/SpaceInsideStringInterpolation:
|
49
|
-
EnforcedStyle: no_space
|
39
|
+
- '**/*.md'
|
50
40
|
|
51
|
-
|
41
|
+
# See https://github.com/rubocop-hq/rubocop/issues/4222
|
42
|
+
Lint/AmbiguousBlockAssociation:
|
52
43
|
Exclude:
|
53
|
-
- 'spec
|
44
|
+
- 'spec/**/*'
|
45
|
+
- '**/*.md'
|
54
46
|
|
55
|
-
Lint/
|
56
|
-
Enabled: false
|
57
|
-
|
58
|
-
Lint/AmbiguousRegexpLiteral:
|
59
|
-
Enabled: false
|
60
|
-
|
61
|
-
Metrics/BlockLength:
|
47
|
+
Lint/DuplicateMethods:
|
62
48
|
Exclude:
|
63
|
-
- '
|
49
|
+
- '**/*.md'
|
64
50
|
|
65
|
-
|
51
|
+
Naming/FileName:
|
66
52
|
Exclude:
|
67
|
-
- '
|
53
|
+
- '**/*.md'
|
68
54
|
|
69
|
-
|
70
|
-
Max: 100
|
55
|
+
Layout/InitialIndentation:
|
71
56
|
Exclude:
|
72
|
-
- '
|
73
|
-
|
74
|
-
Rails/Date:
|
75
|
-
Enabled: false
|
76
|
-
|
77
|
-
Rails/TimeZone:
|
78
|
-
Enabled: false
|
79
|
-
|
80
|
-
Gemspec/OrderedDependencies:
|
81
|
-
Enabled: false
|
57
|
+
- 'CHANGELOG.md'
|
data/.travis.yml
CHANGED
@@ -2,9 +2,14 @@ language: ruby
|
|
2
2
|
cache: bundler
|
3
3
|
matrix:
|
4
4
|
include:
|
5
|
-
- rvm: 2.2
|
5
|
+
- rvm: 2.4.2
|
6
6
|
gemfile: gemfiles/rails32.gemfile
|
7
7
|
- rvm: 2.4.3
|
8
8
|
gemfile: gemfiles/rails42.gemfile
|
9
9
|
- rvm: 2.5.0
|
10
10
|
gemfile: gemfiles/rails5.gemfile
|
11
|
+
- rvm: 2.6.2
|
12
|
+
gemfile: gemfiles/rails6.gemfile
|
13
|
+
allow_failures:
|
14
|
+
- rvm: 2.4.2
|
15
|
+
gemfile: gemfiles/rails32.gemfile
|
data/Changelog.md
CHANGED
@@ -1,13 +1,17 @@
|
|
1
1
|
# Change log
|
2
2
|
|
3
|
-
## master
|
3
|
+
## master (unreleased)
|
4
|
+
|
5
|
+
## 1.2.0 (2019-05-20)
|
6
|
+
|
7
|
+
- **Require Ruby 2.4+**
|
4
8
|
|
5
9
|
## 1.1.6
|
6
10
|
|
7
11
|
- [Fixes [#41](https://github.com/palkan/influxer/issues/41)] Fix query building with empty arrays in `where` clause ([@dimiii][])
|
8
12
|
|
9
13
|
[PR](https://github.com/palkan/influxer/pull/44)
|
10
|
-
|
14
|
+
|
11
15
|
**BREAKING:** `where.not` now returns non-empty result for an empty array.
|
12
16
|
|
13
17
|
- Support of year alias in queries ([@dimiii][])
|
data/Gemfile
CHANGED
@@ -1,10 +1,13 @@
|
|
1
1
|
source "https://rubygems.org"
|
2
2
|
gemspec
|
3
3
|
|
4
|
-
local_gemfile =
|
4
|
+
local_gemfile = "Gemfile.local"
|
5
|
+
|
6
|
+
gem "pry-byebug", platform: :mri
|
5
7
|
|
6
8
|
if File.exist?(local_gemfile)
|
7
9
|
eval(File.read(local_gemfile)) # rubocop:disable Lint/Eval
|
8
10
|
else
|
9
|
-
gem
|
11
|
+
gem "activerecord", "~>4.2"
|
12
|
+
gem "sqlite3", "~> 1.3.0"
|
10
13
|
end
|
data/MIT-LICENSE
CHANGED
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 4+ compatible!
|
6
|
+
**NOTE**: Influxer is Rails 4+ compatible! (Rails 3.2 support is still included but no longer required to pass all the tests).
|
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
|
-
- Special query methods for InfluxDB:
|
11
|
+
- Special query methods for InfluxDB:
|
12
12
|
- `time` - group by time (e.g. `Metrics.time(:hour) => # select * ... group by time(1h)`);
|
13
13
|
- `past` - get only points for last hour/minute/whatever (e.g. `Metrics.past(:day) => # select * ... where time > now() - 1d`);
|
14
14
|
- `since` - get only points since date (e.g. `Metrics.since(Time.utc(2014,12,31)) => # select * ... where time > 1419984000s`);
|
15
15
|
- `merge` - merge series.
|
16
16
|
- Scopes support
|
17
17
|
```ruby
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
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
27
|
# => select * from "metrics" group by time(1h) where account_id=1 limit 1000
|
28
28
|
|
29
|
-
|
29
|
+
Metrics.unlimited.by_account(1).time(:week)
|
30
30
|
# => select * from "metrics" group by time(1w) where account_id=1
|
31
31
|
|
32
32
|
```
|
33
33
|
- Integrate with your model:
|
34
34
|
```ruby
|
35
|
-
|
36
|
-
|
35
|
+
class UserVisits < Influxer::Metrics
|
36
|
+
end
|
37
37
|
|
38
|
-
|
39
|
-
|
40
|
-
|
38
|
+
class User < ActiveRecord::Base
|
39
|
+
has_metrics :visits
|
40
|
+
end
|
41
41
|
|
42
|
-
|
43
|
-
|
42
|
+
user = User.find(1)
|
43
|
+
user.visits.write(page_id: "home")
|
44
44
|
#=> < creates point {user_id: 1, page_id: 'home'} in 'user_visits' series >
|
45
45
|
|
46
|
-
|
46
|
+
user.visits.where(page_id: "home")
|
47
47
|
#=> select * from user_visits where page_id='home'
|
48
48
|
```
|
49
|
-
|
49
|
+
|
50
50
|
Find more on [Wiki](https://github.com/palkan/influxer/wiki).
|
data/Rakefile
CHANGED
@@ -1,6 +1,8 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require "bundler/gem_tasks"
|
2
4
|
|
3
|
-
require
|
5
|
+
require "rspec/core/rake_task"
|
4
6
|
RSpec::Core::RakeTask.new(:spec)
|
5
7
|
|
6
8
|
require "rubocop/rake_task"
|
@@ -9,5 +11,5 @@ RuboCop::RakeTask.new
|
|
9
11
|
task default: [:rubocop, :spec]
|
10
12
|
|
11
13
|
task :console do
|
12
|
-
sh
|
14
|
+
sh "pry -r ./lib/influxer.rb"
|
13
15
|
end
|
data/bin/console
ADDED
data/gemfiles/rails32.gemfile
CHANGED
data/gemfiles/rails42.gemfile
CHANGED
data/gemfiles/rails5.gemfile
CHANGED
data/influxer.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
$LOAD_PATH.push File.expand_path(
|
3
|
+
$LOAD_PATH.push File.expand_path("lib", __dir__)
|
4
4
|
|
5
5
|
require "influxer/version"
|
6
6
|
|
@@ -17,17 +17,24 @@ Gem::Specification.new do |s|
|
|
17
17
|
s.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
|
18
18
|
s.require_paths = ["lib"]
|
19
19
|
|
20
|
-
s.
|
20
|
+
s.required_ruby_version = ">= 2.4.0"
|
21
|
+
|
22
|
+
s.metadata = {
|
23
|
+
"bug_tracker_uri" => "http://github.com/palkan/influxer/issues",
|
24
|
+
"changelog_uri" => "https://github.com/palkan/influxer/blob/master/Changelog.md",
|
25
|
+
"documentation_uri" => "http://github.com/palkan/influxer",
|
26
|
+
"homepage_uri" => "http://github.com/palkan/influxer",
|
27
|
+
"source_code_uri" => "http://github.com/palkan/influxer"
|
28
|
+
}
|
29
|
+
|
30
|
+
s.add_dependency "activemodel", ">= 3.2.0"
|
21
31
|
s.add_dependency "influxdb", "~> 0.3"
|
22
|
-
s.add_dependency "anyway_config", "
|
32
|
+
s.add_dependency "anyway_config", ">= 1.0"
|
23
33
|
|
24
34
|
s.add_development_dependency "timecop"
|
25
|
-
s.add_development_dependency "
|
26
|
-
s.add_development_dependency 'rake', '~> 10.1'
|
27
|
-
s.add_development_dependency 'sqlite3'
|
28
|
-
s.add_development_dependency 'activerecord', '>= 3.2.0'
|
29
|
-
s.add_development_dependency 'pry-byebug'
|
35
|
+
s.add_development_dependency "rake", "~> 10.1"
|
30
36
|
s.add_development_dependency "rspec", ">= 3.1.0"
|
37
|
+
s.add_development_dependency "standard", "~> 0.0.39"
|
38
|
+
s.add_development_dependency "rubocop-md", "~> 0.2.0"
|
31
39
|
s.add_development_dependency "webmock", "~> 2.1"
|
32
|
-
s.add_development_dependency "rubocop", "~> 0.52"
|
33
40
|
end
|
data/lib/influxer.rb
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
3
|
+
require "influxer/version"
|
4
|
+
require "active_model"
|
5
|
+
require "active_support/core_ext"
|
5
6
|
|
6
7
|
# Rails client for InfluxDB
|
7
8
|
module Influxer
|
@@ -9,16 +10,16 @@ module Influxer
|
|
9
10
|
ActiveModel::VERSION::MAJOR == 3
|
10
11
|
end
|
11
12
|
|
12
|
-
require
|
13
|
-
require
|
14
|
-
require
|
13
|
+
require "influxer/config"
|
14
|
+
require "influxer/client"
|
15
|
+
require "influxer/metrics/metrics"
|
15
16
|
|
16
17
|
module Model # :nodoc:
|
17
|
-
require
|
18
|
+
require "influxer/model"
|
18
19
|
end
|
19
20
|
|
20
|
-
require
|
21
|
-
require
|
21
|
+
require "influxer/rails/client" if defined?(Rails)
|
22
|
+
require "influxer/engine" if defined?(Rails)
|
22
23
|
|
23
24
|
def self.config
|
24
25
|
@config ||= Config.new
|
@@ -33,7 +34,7 @@ module Influxer
|
|
33
34
|
end
|
34
35
|
|
35
36
|
def self.reset!
|
36
|
-
@client
|
37
|
+
@client&.stop!
|
37
38
|
@config = nil
|
38
39
|
@client = nil
|
39
40
|
end
|
data/lib/influxer/client.rb
CHANGED
data/lib/influxer/config.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
3
|
+
require "anyway_config"
|
4
4
|
|
5
5
|
module Influxer
|
6
6
|
# Influxer configuration
|
@@ -28,8 +28,8 @@ module Influxer
|
|
28
28
|
:denormalize,
|
29
29
|
:udp,
|
30
30
|
:async,
|
31
|
-
database:
|
32
|
-
time_precision:
|
31
|
+
database: "db",
|
32
|
+
time_precision: "ns",
|
33
33
|
cache: false,
|
34
34
|
time_duration_suffix_enabled: false
|
35
35
|
|
data/lib/influxer/engine.rb
CHANGED
@@ -5,10 +5,8 @@ module Influxer
|
|
5
5
|
# Replacement of ActiveModel::Model for ActiveModel 3
|
6
6
|
module Model
|
7
7
|
def initialize(attributes = {})
|
8
|
-
|
9
|
-
|
10
|
-
public_send("#{attr}=", value)
|
11
|
-
end
|
8
|
+
attributes&.each do |attr, value|
|
9
|
+
public_send("#{attr}=", value)
|
12
10
|
end
|
13
11
|
|
14
12
|
super()
|