groupdate 2.2.0 → 2.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +6 -0
- data/lib/groupdate/active_record.rb +10 -0
- data/lib/groupdate/version.rb +1 -1
- data/test/test_helper.rb +16 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 61482d521349112fbb247de01da256b7d2559574
|
4
|
+
data.tar.gz: ef39227bacbce05f6d382f4e7e70c8f3a69eea3d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4b054169e094d93790241c3757e3f6171058e2379655394c8060db79417fb6bcafa39f7612f4462fc3ea2d6befd11dcfa700a1bde9073ab37037d2714db1ca8d
|
7
|
+
data.tar.gz: 478d53080c29fd79b2965c7804a76a16451f239151bb839aa26040d874d05f1c0bf83ba730b3f23ba670c6d8ffb35028e69d9f147328c735efca669422ead0f9
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -149,6 +149,12 @@ Supports the same options as above
|
|
149
149
|
users.group_by_day(time_zone: time_zone){|u| u.created_at }
|
150
150
|
```
|
151
151
|
|
152
|
+
Count
|
153
|
+
|
154
|
+
```ruby
|
155
|
+
Hash[ users.group_by_day{|u| u.created_at }.map{|k, v| [k, v.size] } ]
|
156
|
+
```
|
157
|
+
|
152
158
|
## Installation
|
153
159
|
|
154
160
|
Add this line to your application’s Gemfile:
|
@@ -24,6 +24,16 @@ module ActiveRecord
|
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
27
|
+
module ActiveRecord
|
28
|
+
module Associations
|
29
|
+
class CollectionProxy
|
30
|
+
if ActiveRecord::VERSION::MAJOR == 3
|
31
|
+
delegate *Groupdate::METHODS, :to => :scoped
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
27
37
|
# hack for **unfixed** rails issue
|
28
38
|
# https://github.com/rails/rails/issues/7121
|
29
39
|
module ActiveRecord
|
data/lib/groupdate/version.rb
CHANGED
data/test/test_helper.rb
CHANGED
@@ -18,6 +18,10 @@ ActiveRecord::Base.default_timezone = :utc
|
|
18
18
|
ActiveRecord::Base.time_zone_aware_attributes = true
|
19
19
|
|
20
20
|
class User < ActiveRecord::Base
|
21
|
+
has_many :posts
|
22
|
+
end
|
23
|
+
|
24
|
+
class Post < ActiveRecord::Base
|
21
25
|
end
|
22
26
|
|
23
27
|
# migrations
|
@@ -29,6 +33,11 @@ end
|
|
29
33
|
t.integer :score
|
30
34
|
t.timestamp :created_at
|
31
35
|
end
|
36
|
+
|
37
|
+
ActiveRecord::Migration.create_table :posts, :force => true do |t|
|
38
|
+
t.references :user
|
39
|
+
t.timestamp :created_at
|
40
|
+
end
|
32
41
|
end
|
33
42
|
|
34
43
|
module TestGroupdate
|
@@ -606,6 +615,13 @@ module TestGroupdate
|
|
606
615
|
assert_equal ({[1, "Sun"] => 1}), User.group(:score).group_by_week(:created_at, format: "%a").count
|
607
616
|
end
|
608
617
|
|
618
|
+
# associations
|
619
|
+
|
620
|
+
def test_associations
|
621
|
+
user = create_user("2014-03-01 00:00:00 UTC")
|
622
|
+
assert_empty user.posts.group_by_day(:created_at).count
|
623
|
+
end
|
624
|
+
|
609
625
|
# helpers
|
610
626
|
|
611
627
|
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.2.
|
4
|
+
version: 2.2.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-06-
|
11
|
+
date: 2014-06-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|