groupdate 2.1.0 → 2.1.1
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 +19 -14
- data/lib/groupdate/series.rb +7 -2
- data/lib/groupdate/version.rb +1 -1
- data/test/test_helper.rb +6 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 358ad13de46aa60a282d59df8b6de77acfced7b7
|
4
|
+
data.tar.gz: c90febd166be21d77ce02aac0335b0691ffb8950
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 69a1f081be83ddd6bf8d36ce2839bc47957b64ca35f2b71f61a545cf0f4c77fcc80e1a2fbc216aaa5f5a7429c45b1fb07139b99ca640f0efa068454e0965cece
|
7
|
+
data.tar.gz: 29865ae92770fed0d36ed7e4d9d21042057a152e12ed74d49ee0214328a960d3b6008ce63c6fca497982920dbdd5f322ffc0986976ef419c477b7995f37cda8c
|
data/CHANGELOG.md
CHANGED
@@ -1,37 +1,42 @@
|
|
1
|
-
|
1
|
+
## 2.1.1
|
2
2
|
|
3
|
-
-
|
4
|
-
-
|
3
|
+
- Fixed format option with multiple groups
|
4
|
+
- Better error message if time zone support is missing for MySQL
|
5
5
|
|
6
|
-
|
6
|
+
## 2.1.0
|
7
7
|
|
8
|
-
-
|
9
|
-
-
|
10
|
-
- subsequent methods no longer modify relation
|
8
|
+
- Added last option
|
9
|
+
- Added format option
|
11
10
|
|
12
|
-
|
11
|
+
## 2.0.4
|
13
12
|
|
14
|
-
-
|
13
|
+
- Added multiple groups
|
14
|
+
- Added order
|
15
|
+
- Subsequent methods no longer modify relation
|
15
16
|
|
16
|
-
|
17
|
+
## 2.0.3
|
18
|
+
|
19
|
+
- Implemented respond_to?
|
20
|
+
|
21
|
+
## 2.0.2
|
17
22
|
|
18
23
|
- where, joins, and includes no longer need to be before the group_by method
|
19
24
|
|
20
|
-
|
25
|
+
## 2.0.1
|
21
26
|
|
22
27
|
- Use time zone instead of UTC for results
|
23
28
|
|
24
|
-
|
29
|
+
## 2.0.0
|
25
30
|
|
26
31
|
- Returns entire series by default
|
27
32
|
- Added day_start option
|
28
33
|
- Better interface
|
29
34
|
|
30
|
-
|
35
|
+
## 1.0.5
|
31
36
|
|
32
37
|
- Added global time_zone option
|
33
38
|
|
34
|
-
|
39
|
+
## 1.0.4
|
35
40
|
|
36
41
|
- Added global week_start option
|
37
42
|
- Fixed bug with NULL values and series
|
data/lib/groupdate/series.rb
CHANGED
@@ -56,7 +56,12 @@ module Groupdate
|
|
56
56
|
lambda{|k| (k.is_a?(String) ? utc.parse(k) : k.to_time).in_time_zone(@time_zone) }
|
57
57
|
end
|
58
58
|
|
59
|
-
count =
|
59
|
+
count =
|
60
|
+
begin
|
61
|
+
Hash[ relation.send(method, *args, &block).map{|k, v| [multiple_groups ? k[0...@group_index] + [cast_method.call(k[@group_index])] + k[(@group_index + 1)..-1] : cast_method.call(k), v] } ]
|
62
|
+
rescue NoMethodError
|
63
|
+
raise "Be sure to install time zone support - https://github.com/ankane/groupdate#for-mysql"
|
64
|
+
end
|
60
65
|
|
61
66
|
series =
|
62
67
|
case @field
|
@@ -128,7 +133,7 @@ module Groupdate
|
|
128
133
|
end
|
129
134
|
|
130
135
|
Hash[series.map do |k|
|
131
|
-
[key_format.call(k), count[k] || 0]
|
136
|
+
[multiple_groups ? k[0...@group_index] + [key_format.call(k[@group_index])] + k[(@group_index + 1)..-1] : key_format.call(k), count[k] || 0]
|
132
137
|
end]
|
133
138
|
end
|
134
139
|
|
data/lib/groupdate/version.rb
CHANGED
data/test/test_helper.rb
CHANGED
@@ -595,6 +595,12 @@ module TestGroupdate
|
|
595
595
|
assert_format :day_of_week, "Sun", "%a", week_start: :sat
|
596
596
|
end
|
597
597
|
|
598
|
+
def test_format_multiple_groups
|
599
|
+
create_user "2014-03-01 00:00:00 UTC"
|
600
|
+
assert_equal ({["Sun", 1] => 1}), User.group_by_week(:created_at, format: "%a").group(:score).count
|
601
|
+
assert_equal ({[1, "Sun"] => 1}), User.group(:score).group_by_week(:created_at, format: "%a").count
|
602
|
+
end
|
603
|
+
|
598
604
|
# helpers
|
599
605
|
|
600
606
|
def assert_format(method, expected, format, options = {})
|
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: 2.1.
|
4
|
+
version: 2.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Kane
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-05-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -138,7 +138,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
138
138
|
version: '0'
|
139
139
|
requirements: []
|
140
140
|
rubyforge_project:
|
141
|
-
rubygems_version: 2.2.
|
141
|
+
rubygems_version: 2.2.2
|
142
142
|
signing_key:
|
143
143
|
specification_version: 4
|
144
144
|
summary: The simplest way to group temporal data
|