groupdate 4.2.0 → 4.3.0
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 +4 -4
- data/CHANGELOG.md +41 -35
- data/README.md +5 -5
- data/lib/groupdate/enumerable.rb +11 -10
- data/lib/groupdate/query_methods.rb +2 -0
- data/lib/groupdate/series_builder.rb +2 -2
- data/lib/groupdate/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c661470fa1d3e85d4cff490be69845b175f5c095956ae674bda74e25e8713d1e
|
4
|
+
data.tar.gz: d2f4a2adb3dec4d73fdfc36302514c7c9c051766bb2703057b4074e3f480223c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f7e3309e4f687cb88839c23d07f6ad9dce57ee3f8f18c335d695d79fe4c0d7fe4e236d1362071180ba07daf3eb6edd62ace05f4d15e0f4392c2dc48e81139c17
|
7
|
+
data.tar.gz: 2b1682b63429bb482b01cb8f50a5bd0ab03a0677b9a806244c7d26054579611b1678f056c713d23278cd5cd3e8616def5c77d0897caccda7c5a6d297e4eaa863
|
data/CHANGELOG.md
CHANGED
@@ -1,36 +1,42 @@
|
|
1
|
-
## 4.
|
1
|
+
## 4.3.0 (2019-12-26)
|
2
|
+
|
3
|
+
- Fixed error with empty results in Ruby 2.7
|
4
|
+
- Fixed deprecation warnings in Ruby 2.7
|
5
|
+
- Deprecated positional arguments for time zone and range
|
6
|
+
|
7
|
+
## 4.2.0 (2019-10-28)
|
2
8
|
|
3
9
|
- Added `day_of_year`
|
4
10
|
- Dropped support for Rails 4.2
|
5
11
|
|
6
|
-
## 4.1.2
|
12
|
+
## 4.1.2 (2019-05-26)
|
7
13
|
|
8
14
|
- Fixed error with empty data and `current: false`
|
9
15
|
- Fixed error in time zone check for Rails < 5.2
|
10
16
|
- Prevent infinite loop with endless ranges
|
11
17
|
|
12
|
-
## 4.1.1
|
18
|
+
## 4.1.1 (2018-12-11)
|
13
19
|
|
14
20
|
- Made column resolution consistent with `group`
|
15
21
|
- Added support for `alias_attribute`
|
16
22
|
|
17
|
-
## 4.1.0
|
23
|
+
## 4.1.0 (2018-11-04)
|
18
24
|
|
19
25
|
- Many performance improvements
|
20
26
|
- Added check for consistent time zone info
|
21
27
|
- Fixed error message for invalid queries with MySQL and SQLite
|
22
28
|
- Fixed issue with enumerable methods ignoring nils
|
23
29
|
|
24
|
-
## 4.0.2
|
30
|
+
## 4.0.2 (2018-10-15)
|
25
31
|
|
26
32
|
- Make `current` option work without `last`
|
27
33
|
- Fixed default value for `maximum`, `minimum`, and `average` (periods with no results now return `nil` instead of `0`, pass `default_value: 0` for previous behavior)
|
28
34
|
|
29
|
-
## 4.0.1
|
35
|
+
## 4.0.1 (2018-05-03)
|
30
36
|
|
31
37
|
- Fixed incorrect range with `last` option near time change
|
32
38
|
|
33
|
-
## 4.0.0
|
39
|
+
## 4.0.0 (2018-02-21)
|
34
40
|
|
35
41
|
- Custom calculation methods are supported by default - `groupdate_calculation_methods` is no longer needed
|
36
42
|
|
@@ -42,37 +48,37 @@ Breaking changes
|
|
42
48
|
- `week_start` now affects `day_of_week`
|
43
49
|
- Removed support for `reverse_order` (was never supported in Rails 5)
|
44
50
|
|
45
|
-
## 3.2.1
|
51
|
+
## 3.2.1 (2018-02-21)
|
46
52
|
|
47
53
|
- Added `minute_of_hour`
|
48
54
|
- Added support for `unscoped`
|
49
55
|
|
50
|
-
## 3.2.0
|
56
|
+
## 3.2.0 (2017-01-30)
|
51
57
|
|
52
58
|
- Added limited support for SQLite
|
53
59
|
|
54
|
-
## 3.1.1
|
60
|
+
## 3.1.1 (2016-10-25)
|
55
61
|
|
56
62
|
- Fixed `current: false`
|
57
63
|
- Fixed `last` with `group_by_quarter`
|
58
64
|
- Raise `ArgumentError` when `last` option is not supported
|
59
65
|
|
60
|
-
## 3.1.0
|
66
|
+
## 3.1.0 (2016-10-22)
|
61
67
|
|
62
68
|
- Better support for date columns with `time_zone: false`
|
63
69
|
- Better date range handling for `range` option
|
64
70
|
|
65
|
-
## 3.0.2
|
71
|
+
## 3.0.2 (2016-08-09)
|
66
72
|
|
67
73
|
- Fixed `group_by_period` with associations
|
68
74
|
- Fixed `week_start` option for enumerables
|
69
75
|
|
70
|
-
## 3.0.1
|
76
|
+
## 3.0.1 (2016-07-13)
|
71
77
|
|
72
78
|
- Added support for Redshift
|
73
79
|
- Fix for infinite loop in certain cases for Rails 5
|
74
80
|
|
75
|
-
## 3.0.0
|
81
|
+
## 3.0.0 (2016-05-30)
|
76
82
|
|
77
83
|
Breaking changes
|
78
84
|
|
@@ -80,16 +86,16 @@ Breaking changes
|
|
80
86
|
- Array and hash methods no longer return the entire series by default. Use `series: true` for the previous behavior.
|
81
87
|
- The `series: false` option now returns the correct types and order, and plays nicely with other options.
|
82
88
|
|
83
|
-
## 2.5.3
|
89
|
+
## 2.5.3 (2016-04-28)
|
84
90
|
|
85
91
|
- All tests green with `mysql` gem
|
86
92
|
- Added support for decimal day start
|
87
93
|
|
88
|
-
## 2.5.2
|
94
|
+
## 2.5.2 (2016-02-16)
|
89
95
|
|
90
96
|
- Added `dates` option to return dates for day, week, month, quarter, and year
|
91
97
|
|
92
|
-
## 2.5.1
|
98
|
+
## 2.5.1 (2016-02-03)
|
93
99
|
|
94
100
|
- Added `group_by_quarter`
|
95
101
|
- Added `default_value` option
|
@@ -97,13 +103,13 @@ Breaking changes
|
|
97
103
|
- Raise `ArgumentError` if no field specified
|
98
104
|
- Added support for ActiveRecord 5 beta
|
99
105
|
|
100
|
-
## 2.5.0
|
106
|
+
## 2.5.0 (2015-09-29)
|
101
107
|
|
102
108
|
- Added `group_by_period` method
|
103
109
|
- Added `current` option
|
104
110
|
- Raise `ArgumentError` if no block given to enumerable
|
105
111
|
|
106
|
-
## 2.4.0
|
112
|
+
## 2.4.0 (2014-12-28)
|
107
113
|
|
108
114
|
- Added localization
|
109
115
|
- Added `carry_forward` option
|
@@ -111,77 +117,77 @@ Breaking changes
|
|
111
117
|
- Fixed issue w/ Brasilia Summer Time
|
112
118
|
- Fixed issues w/ ActiveRecord 4.2
|
113
119
|
|
114
|
-
## 2.3.0
|
120
|
+
## 2.3.0 (2014-08-31)
|
115
121
|
|
116
122
|
- Raise error when ActiveRecord::Base.default_timezone is not `:utc`
|
117
123
|
- Added `day_of_month`
|
118
124
|
- Added `month_of_year`
|
119
125
|
- Do not quote column name
|
120
126
|
|
121
|
-
## 2.2.1
|
127
|
+
## 2.2.1 (2014-06-23)
|
122
128
|
|
123
129
|
- Fixed ActiveRecord 3 associations
|
124
130
|
|
125
|
-
## 2.2.0
|
131
|
+
## 2.2.0 (2014-06-22)
|
126
132
|
|
127
133
|
- Added support for arrays and hashes
|
128
134
|
|
129
|
-
## 2.1.1
|
135
|
+
## 2.1.1 (2014-05-17)
|
130
136
|
|
131
137
|
- Fixed format option with multiple groups
|
132
138
|
- Better error message if time zone support is missing for MySQL
|
133
139
|
|
134
|
-
## 2.1.0
|
140
|
+
## 2.1.0 (2014-03-16)
|
135
141
|
|
136
142
|
- Added last option
|
137
143
|
- Added format option
|
138
144
|
|
139
|
-
## 2.0.4
|
145
|
+
## 2.0.4 (2014-03-12)
|
140
146
|
|
141
147
|
- Added multiple groups
|
142
148
|
- Added order
|
143
149
|
- Subsequent methods no longer modify relation
|
144
150
|
|
145
|
-
## 2.0.3
|
151
|
+
## 2.0.3 (2014-03-11)
|
146
152
|
|
147
153
|
- Implemented respond_to?
|
148
154
|
|
149
|
-
## 2.0.2
|
155
|
+
## 2.0.2 (2014-03-11)
|
150
156
|
|
151
157
|
- where, joins, and includes no longer need to be before the group_by method
|
152
158
|
|
153
|
-
## 2.0.1
|
159
|
+
## 2.0.1 (2014-03-07)
|
154
160
|
|
155
161
|
- Use time zone instead of UTC for results
|
156
162
|
|
157
|
-
## 2.0.0
|
163
|
+
## 2.0.0 (2014-03-07)
|
158
164
|
|
159
165
|
- Returns entire series by default
|
160
166
|
- Added day_start option
|
161
167
|
- Better interface
|
162
168
|
|
163
|
-
## 1.0.5
|
169
|
+
## 1.0.5 (2014-03-06)
|
164
170
|
|
165
171
|
- Added global time_zone option
|
166
172
|
|
167
|
-
## 1.0.4
|
173
|
+
## 1.0.4 (2013-07-20)
|
168
174
|
|
169
175
|
- Added global week_start option
|
170
176
|
- Fixed bug with NULL values and series
|
171
177
|
|
172
|
-
## 1.0.3
|
178
|
+
## 1.0.3 (2013-07-05)
|
173
179
|
|
174
180
|
- Fixed deprecation warning when used with will_paginate
|
175
181
|
- Fixed bug with DateTime series
|
176
182
|
|
177
|
-
## 1.0.2
|
183
|
+
## 1.0.2 (2013-06-10)
|
178
184
|
|
179
185
|
- Added :start option for custom week start for group_by_week
|
180
186
|
|
181
|
-
## 1.0.1
|
187
|
+
## 1.0.1 (2013-06-03)
|
182
188
|
|
183
189
|
- Fixed series for Rails < 3.2 and MySQL
|
184
190
|
|
185
|
-
## 1.0.0
|
191
|
+
## 1.0.0 (2013-05-15)
|
186
192
|
|
187
193
|
- First major release
|
data/README.md
CHANGED
@@ -226,23 +226,23 @@ Supports the same options as above
|
|
226
226
|
users.group_by_day(time_zone: time_zone) { |u| u.created_at }
|
227
227
|
```
|
228
228
|
|
229
|
-
|
229
|
+
Get the entire series with:
|
230
230
|
|
231
231
|
```ruby
|
232
|
-
users.group_by_day { |u| u.created_at }
|
232
|
+
users.group_by_day(series: true) { |u| u.created_at }
|
233
233
|
```
|
234
234
|
|
235
|
-
|
235
|
+
Count
|
236
236
|
|
237
237
|
```ruby
|
238
|
-
users.group_by_day
|
238
|
+
users.group_by_day { |u| u.created_at }.map { |k, v| [k, v.count] }.to_h
|
239
239
|
```
|
240
240
|
|
241
241
|
## Additional Instructions
|
242
242
|
|
243
243
|
### For MySQL
|
244
244
|
|
245
|
-
[Time zone support](https://dev.mysql.com/doc/refman/
|
245
|
+
[Time zone support](https://dev.mysql.com/doc/refman/8.0/en/time-zone-support.html) must be installed on the server.
|
246
246
|
|
247
247
|
```sh
|
248
248
|
mysql_tzinfo_to_sql /usr/share/zoneinfo | mysql -u root mysql
|
data/lib/groupdate/enumerable.rb
CHANGED
@@ -1,31 +1,32 @@
|
|
1
1
|
module Enumerable
|
2
2
|
Groupdate::PERIODS.each do |period|
|
3
|
-
define_method :"group_by_#{period}" do |*args, &block|
|
3
|
+
define_method :"group_by_#{period}" do |*args, **options, &block|
|
4
4
|
if block
|
5
|
-
|
5
|
+
# TODO throw error in Groupdate 5
|
6
|
+
warn "[groupdate] positional arguments are deprecated" if args.any?
|
7
|
+
Groupdate::Magic::Enumerable.group_by(self, period, (args[0] || {}).merge(options), &block)
|
6
8
|
elsif respond_to?(:scoping)
|
7
|
-
scoping { @klass.send(:"group_by_#{period}", *args, &block) }
|
9
|
+
scoping { @klass.send(:"group_by_#{period}", *args, **options, &block) }
|
8
10
|
else
|
9
11
|
raise ArgumentError, "no block given"
|
10
12
|
end
|
11
13
|
end
|
12
14
|
end
|
13
15
|
|
14
|
-
def group_by_period(*args, &block)
|
16
|
+
def group_by_period(period, *args, **options, &block)
|
15
17
|
if block || !respond_to?(:scoping)
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
options = options.dup
|
18
|
+
# TODO throw error in Groupdate 5
|
19
|
+
warn "[groupdate] positional arguments are deprecated" if args.any?
|
20
|
+
options = (args[0] || {}).merge(options)
|
20
21
|
# to_sym is unsafe on user input, so convert to strings
|
21
22
|
permitted_periods = ((options.delete(:permit) || Groupdate::PERIODS).map(&:to_sym) & Groupdate::PERIODS).map(&:to_s)
|
22
23
|
if permitted_periods.include?(period.to_s)
|
23
|
-
send("group_by_#{period}", options, &block)
|
24
|
+
send("group_by_#{period}", **options, &block)
|
24
25
|
else
|
25
26
|
raise ArgumentError, "Unpermitted period"
|
26
27
|
end
|
27
28
|
else
|
28
|
-
scoping { @klass.send(:group_by_period, *args, &block) }
|
29
|
+
scoping { @klass.send(:group_by_period, period, *args, **options, &block) }
|
29
30
|
end
|
30
31
|
end
|
31
32
|
end
|
@@ -2,6 +2,8 @@ module Groupdate
|
|
2
2
|
module QueryMethods
|
3
3
|
Groupdate::PERIODS.each do |period|
|
4
4
|
define_method :"group_by_#{period}" do |field, time_zone = nil, range = nil, **options|
|
5
|
+
warn "[groupdate] positional arguments for time zone and range are deprecated" if time_zone || range
|
6
|
+
|
5
7
|
Groupdate::Magic::Relation.generate_relation(self,
|
6
8
|
period: period,
|
7
9
|
field: field,
|
data/lib/groupdate/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: groupdate
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.
|
4
|
+
version: 4.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Kane
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-12-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -160,7 +160,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
160
160
|
- !ruby/object:Gem::Version
|
161
161
|
version: '0'
|
162
162
|
requirements: []
|
163
|
-
rubygems_version: 3.
|
163
|
+
rubygems_version: 3.1.2
|
164
164
|
signing_key:
|
165
165
|
specification_version: 4
|
166
166
|
summary: The simplest way to group temporal data
|