groupdate 2.0.1 → 2.0.2
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 +5 -24
- data/lib/groupdate/series.rb +4 -3
- data/lib/groupdate/version.rb +1 -1
- data/test/test_helper.rb +16 -1
- 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: af27fcb8fcdb2e8bb300ca3ad248690b47b750df
|
4
|
+
data.tar.gz: c7db61278cb56b67bafdb01beceadaa2236e955b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1f1be192a48bc96363a39627f69aaa0d1f598c39f91f3dd0728d47c1c49d2e4bafc15b54e7e3d7437247e5bda8e8b68a452db55e3fff156ab6ab1dce8fa77778
|
7
|
+
data.tar.gz: 681d43a72eb1c7b97c91d923b5de0de2517a114bb202e97a7f902ca9ff24cd71678a4a453736adf71331837058b43fde744aba26e08c419b20ae7a99ffd273ef
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -61,9 +61,9 @@ or
|
|
61
61
|
```ruby
|
62
62
|
User.group_by_week(:created_at, time_zone: "Pacific Time (US & Canada)").count
|
63
63
|
# {
|
64
|
-
# 2013-03-
|
65
|
-
# 2013-03-
|
66
|
-
# 2013-03-
|
64
|
+
# 2013-03-10 00:00:00 PST => 70,
|
65
|
+
# 2013-03-17 00:00:00 PDT => 54,
|
66
|
+
# 2013-03-24 00:00:00 PDT => 80
|
67
67
|
# }
|
68
68
|
```
|
69
69
|
|
@@ -135,29 +135,10 @@ gem "activerecord-jdbcmysql-adapter", :github => "jruby/activerecord-jdbc-adapte
|
|
135
135
|
|
136
136
|
## Upgrading to 2.0
|
137
137
|
|
138
|
-
Groupdate 2.0 brings a number a great improvements.
|
138
|
+
Groupdate 2.0 brings a number a great improvements. Here are two things to be aware of:
|
139
139
|
|
140
140
|
- the entire series is returned by default
|
141
|
-
-
|
142
|
-
- an improved interface
|
143
|
-
|
144
|
-
However, there are a few things to be aware of when upgrading.
|
145
|
-
|
146
|
-
1. Groupdate methods must come after any `where`, `joins`, or `includes`.
|
147
|
-
|
148
|
-
Throws error
|
149
|
-
|
150
|
-
```ruby
|
151
|
-
User.group_by_day(:created_at).where(company_id: 1).count
|
152
|
-
```
|
153
|
-
|
154
|
-
:moneybag:
|
155
|
-
|
156
|
-
```ruby
|
157
|
-
User.where(company_id: 1).group_by_day(:created_at).count
|
158
|
-
```
|
159
|
-
|
160
|
-
2. `Time` keys are now returned for every database adapter. Some older adapters previously returned `String` keys.
|
141
|
+
- `ActiveSupport::TimeWithZone` keys are now returned for every database adapter - adapters previously returned `Time` or `String` keys
|
161
142
|
|
162
143
|
## History
|
163
144
|
|
data/lib/groupdate/series.rb
CHANGED
@@ -91,10 +91,11 @@ module Groupdate
|
|
91
91
|
# https://github.com/rails/rails/blob/master/activerecord/lib/active_record/relation/calculations.rb
|
92
92
|
if ActiveRecord::Calculations.method_defined?(method)
|
93
93
|
build_series(@relation.send(method, *args, &block))
|
94
|
-
elsif
|
95
|
-
|
94
|
+
elsif @relation.respond_to?(method)
|
95
|
+
@relation = @relation.send(method, *args, &block)
|
96
|
+
self
|
96
97
|
else
|
97
|
-
|
98
|
+
super
|
98
99
|
end
|
99
100
|
end
|
100
101
|
|
data/lib/groupdate/version.rb
CHANGED
data/test/test_helper.rb
CHANGED
@@ -480,6 +480,17 @@ module TestGroupdate
|
|
480
480
|
assert_equal time_zone, User.group_by_day(:created_at, time_zone: time_zone).count.keys.first.time_zone.name
|
481
481
|
end
|
482
482
|
|
483
|
+
def test_where_after
|
484
|
+
create_user "2013-05-01 00:00:00 UTC"
|
485
|
+
create_user "2013-05-02 00:00:00 UTC"
|
486
|
+
expected = {utc.parse("2013-05-02 00:00:00 UTC") => 1}
|
487
|
+
assert_equal expected, User.group_by_day(:created_at).where("created_at > ?", "2013-05-01 00:00:00 UTC").count
|
488
|
+
end
|
489
|
+
|
490
|
+
def test_bad_method
|
491
|
+
assert_raises(NoMethodError) { User.group_by_day(:created_at).no_such_method }
|
492
|
+
end
|
493
|
+
|
483
494
|
# helpers
|
484
495
|
|
485
496
|
def assert_result_time(method, expected, time_str, time_zone = false, options = {})
|
@@ -507,7 +518,11 @@ module TestGroupdate
|
|
507
518
|
end
|
508
519
|
|
509
520
|
def create_user(created_at)
|
510
|
-
User.create! :name => "Andrew", :score => 1, :created_at =>
|
521
|
+
User.create! :name => "Andrew", :score => 1, :created_at => utc.parse(created_at)
|
522
|
+
end
|
523
|
+
|
524
|
+
def utc
|
525
|
+
ActiveSupport::TimeZone["UTC"]
|
511
526
|
end
|
512
527
|
|
513
528
|
def teardown
|
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.0.
|
4
|
+
version: 2.0.2
|
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-
|
11
|
+
date: 2014-03-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|