moving_window 2.0.4 → 2.0.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/moving_window.rb +7 -2
  3. metadata +26 -12
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4a4e42c0b854a1521fba560fe164ee30c9dc5102
4
- data.tar.gz: b91382c6da46108da549dc840f64e2468b5323f3
3
+ metadata.gz: 8b8600921fac71e7f9661fc55c24156011f52036
4
+ data.tar.gz: 212a3dc680424c2129aaca29e66cf458569fe891
5
5
  SHA512:
6
- metadata.gz: 11b7dc8dd7d4f4ab7090d5091e5700fc2ba2a68eb11941ad09ae8bf474534cc682ce574922561bacea49fb55d296747c5757eef860810c01404215170fd017cc
7
- data.tar.gz: e09ec880d393992524d57d9549cf4d67ecd32a2e7318b5b6fee5e550fa03e0e73a512581b36dedab4222e7e310d37348f058feb694c2bc29c96eab6122428977
6
+ metadata.gz: 4132eee6b7f1d00d9e3dc6e5fa08e977705d395a45cb80c83b722ae7de43ee8c1e779220283a739278cbd73cd5662549aa9574f2b5dc0bf0b283363aa94e4166
7
+ data.tar.gz: 9be3dd82e9c55aba23fbd7d2b80011339125f9745dd412b1795f1778aeafa7c64ac05ade8a03dbbb9ab730d298f04af0ed9ff802eaefa2c8cd7d5335422f1527
@@ -13,8 +13,8 @@ class MovingWindow
13
13
 
14
14
  def filter(scope, params = {})
15
15
  column, qualifier = parse(params)
16
- t = scope.table_name
17
- scope.where(["#{t}.#{column} #{qualifier} ? and ?", *timestamps])
16
+ query = columns_sql(scope.table_name, Array.wrap(column))
17
+ scope.where(["#{query} #{qualifier} ? and ?", *timestamps])
18
18
  end
19
19
 
20
20
  private
@@ -31,6 +31,11 @@ class MovingWindow
31
31
  [from, to].sort
32
32
  end
33
33
 
34
+ def columns_sql(table_name, columns)
35
+ columns_string = columns.map { |name| "#{table_name}.#{name}" }.join(',')
36
+ columns.length > 1 ? "COALESCE(#{columns_string})" : columns_string
37
+ end
38
+
34
39
  class Proc < ::Proc
35
40
  attr_writer :negate
36
41
 
metadata CHANGED
@@ -1,55 +1,69 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: moving_window
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.4
4
+ version: 2.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Patuzzo
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-03-23 00:00:00.000000000 Z
11
+ date: 2017-01-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: '0'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '>='
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: activerecord
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '>='
31
+ - - '='
32
+ - !ruby/object:Gem::Version
33
+ version: 3.2.22
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '='
39
+ - !ruby/object:Gem::Version
40
+ version: 3.2.22
41
+ - !ruby/object:Gem::Dependency
42
+ name: sqlite3
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
32
46
  - !ruby/object:Gem::Version
33
47
  version: '0'
34
48
  type: :development
35
49
  prerelease: false
36
50
  version_requirements: !ruby/object:Gem::Requirement
37
51
  requirements:
38
- - - '>='
52
+ - - ">="
39
53
  - !ruby/object:Gem::Version
40
54
  version: '0'
41
55
  - !ruby/object:Gem::Dependency
42
- name: sqlite3
56
+ name: rake
43
57
  requirement: !ruby/object:Gem::Requirement
44
58
  requirements:
45
- - - '>='
59
+ - - ">="
46
60
  - !ruby/object:Gem::Version
47
61
  version: '0'
48
62
  type: :development
49
63
  prerelease: false
50
64
  version_requirements: !ruby/object:Gem::Requirement
51
65
  requirements:
52
- - - '>='
66
+ - - ">="
53
67
  - !ruby/object:Gem::Version
54
68
  version: '0'
55
69
  description: A helper for building scopes that deal with moving windows.
@@ -69,17 +83,17 @@ require_paths:
69
83
  - lib
70
84
  required_ruby_version: !ruby/object:Gem::Requirement
71
85
  requirements:
72
- - - '>='
86
+ - - ">="
73
87
  - !ruby/object:Gem::Version
74
88
  version: '0'
75
89
  required_rubygems_version: !ruby/object:Gem::Requirement
76
90
  requirements:
77
- - - '>='
91
+ - - ">="
78
92
  - !ruby/object:Gem::Version
79
93
  version: '0'
80
94
  requirements: []
81
95
  rubyforge_project:
82
- rubygems_version: 2.0.0
96
+ rubygems_version: 2.6.7
83
97
  signing_key:
84
98
  specification_version: 4
85
99
  summary: Moving Window