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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 08308d10dc780963998b4ebcb906f802dd15f6a7
4
- data.tar.gz: 4e2a7f3a352b94f22287e2e84e4e8830625914ca
3
+ metadata.gz: 358ad13de46aa60a282d59df8b6de77acfced7b7
4
+ data.tar.gz: c90febd166be21d77ce02aac0335b0691ffb8950
5
5
  SHA512:
6
- metadata.gz: d302a57517c823e80b7192a42153bc4a594af23bd1647f6cd7f3eab77a57252882204e22d40e4a6a3a80253be4adce6577cb9fa723d52342f7f8d8cf4a725d77
7
- data.tar.gz: 0fdeb289ba29919be219e0dc1cdaf040552ffdc2ffa1ed5c180178ba8c8f4bb8aa00d8ffb0862eb5030af8996144098b2d03380c96d0a5f97ce248362b148578
6
+ metadata.gz: 69a1f081be83ddd6bf8d36ce2839bc47957b64ca35f2b71f61a545cf0f4c77fcc80e1a2fbc216aaa5f5a7429c45b1fb07139b99ca640f0efa068454e0965cece
7
+ data.tar.gz: 29865ae92770fed0d36ed7e4d9d21042057a152e12ed74d49ee0214328a960d3b6008ce63c6fca497982920dbdd5f322ffc0986976ef419c477b7995f37cda8c
data/CHANGELOG.md CHANGED
@@ -1,37 +1,42 @@
1
- # 2.1.0
1
+ ## 2.1.1
2
2
 
3
- - added last option
4
- - added format option
3
+ - Fixed format option with multiple groups
4
+ - Better error message if time zone support is missing for MySQL
5
5
 
6
- # 2.0.4
6
+ ## 2.1.0
7
7
 
8
- - added multiple groups
9
- - added order
10
- - subsequent methods no longer modify relation
8
+ - Added last option
9
+ - Added format option
11
10
 
12
- # 2.0.3
11
+ ## 2.0.4
13
12
 
14
- - implemented respond_to?
13
+ - Added multiple groups
14
+ - Added order
15
+ - Subsequent methods no longer modify relation
15
16
 
16
- # 2.0.2
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
- # 2.0.1
25
+ ## 2.0.1
21
26
 
22
27
  - Use time zone instead of UTC for results
23
28
 
24
- # 2.0.0
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
- # 1.0.5
35
+ ## 1.0.5
31
36
 
32
37
  - Added global time_zone option
33
38
 
34
- # 1.0.4
39
+ ## 1.0.4
35
40
 
36
41
  - Added global week_start option
37
42
  - Fixed bug with NULL values and series
@@ -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 = 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] } ]
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
 
@@ -1,3 +1,3 @@
1
1
  module Groupdate
2
- VERSION = "2.1.0"
2
+ VERSION = "2.1.1"
3
3
  end
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.0
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-03-17 00:00:00.000000000 Z
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.0
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