groupdate 4.1.1 → 4.1.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 +6 -0
- data/LICENSE.txt +1 -1
- data/README.md +16 -10
- data/lib/groupdate/magic.rb +3 -1
- data/lib/groupdate/series_builder.rb +1 -1
- data/lib/groupdate/version.rb +1 -1
- metadata +7 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 28ba8881c2af7869f774eceebed739e851e81d7d28b53473762260e7c4297134
|
4
|
+
data.tar.gz: e0031f94b52b53255bdbe01c0f72d5c7abcb20d94b02d81bf9e31344a957919a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cb863625ed13dea87c18b31bf897f0e6d6c00bb02b3c41aaf08a11221cc52a8cbfea5cb4f8fe991d33552b0f9294c9c2c04bfb1c220bdcfb8688dbacc848ceed
|
7
|
+
data.tar.gz: 805c5290d0652b2f82c3426fb253dc962bc9c2e4903b3edb1aa2451dc252f0c94bbc7737d3c1b8ddd429c5844ca99c8c01b1e872f1efd4980a747eb4cd2c4294
|
data/CHANGELOG.md
CHANGED
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
@@ -17,7 +17,17 @@ Supports PostgreSQL, MySQL, and Redshift, plus arrays and hashes (and limited su
|
|
17
17
|
|
18
18
|
[![Build Status](https://travis-ci.org/ankane/groupdate.svg?branch=master)](https://travis-ci.org/ankane/groupdate)
|
19
19
|
|
20
|
-
##
|
20
|
+
## Installation
|
21
|
+
|
22
|
+
Add this line to your application’s Gemfile:
|
23
|
+
|
24
|
+
```ruby
|
25
|
+
gem 'groupdate'
|
26
|
+
```
|
27
|
+
|
28
|
+
For MySQL and SQLite, also follow [these instructions](#additional-instructions).
|
29
|
+
|
30
|
+
## Getting Started
|
21
31
|
|
22
32
|
```ruby
|
23
33
|
User.group_by_day(:created_at).count
|
@@ -221,15 +231,9 @@ Count
|
|
221
231
|
Hash[ users.group_by_day { |u| u.created_at }.map { |k, v| [k, v.size] } ]
|
222
232
|
```
|
223
233
|
|
224
|
-
##
|
225
|
-
|
226
|
-
Add this line to your application’s Gemfile:
|
227
|
-
|
228
|
-
```ruby
|
229
|
-
gem 'groupdate'
|
230
|
-
```
|
234
|
+
## Additional Instructions
|
231
235
|
|
232
|
-
|
236
|
+
### For MySQL
|
233
237
|
|
234
238
|
[Time zone support](https://dev.mysql.com/doc/refman/5.7/en/time-zone-support.html) must be installed on the server.
|
235
239
|
|
@@ -247,7 +251,7 @@ SELECT CONVERT_TZ(NOW(), '+00:00', 'Pacific/Honolulu');
|
|
247
251
|
|
248
252
|
It should return the time instead of `NULL`.
|
249
253
|
|
250
|
-
|
254
|
+
### For SQLite
|
251
255
|
|
252
256
|
Groupdate has limited support for SQLite.
|
253
257
|
|
@@ -301,3 +305,5 @@ Everyone is encouraged to help improve this project. Here are a few ways you can
|
|
301
305
|
- Fix bugs and [submit pull requests](https://github.com/ankane/groupdate/pulls)
|
302
306
|
- Write, clarify, or fix documentation
|
303
307
|
- Suggest or add new features
|
308
|
+
|
309
|
+
To get started with development and testing, check out the [Contributing Guide](CONTRIBUTING.md).
|
data/lib/groupdate/magic.rb
CHANGED
@@ -13,6 +13,7 @@ module Groupdate
|
|
13
13
|
|
14
14
|
raise Groupdate::Error, "Unrecognized time zone" unless time_zone
|
15
15
|
raise Groupdate::Error, "Unrecognized :week_start option" if period == :week && !week_start
|
16
|
+
raise Groupdate::Error, "Cannot use endless range for :range option" if options[:range].is_a?(Range) && !options[:range].end
|
16
17
|
end
|
17
18
|
|
18
19
|
def time_zone
|
@@ -110,7 +111,8 @@ module Groupdate
|
|
110
111
|
|
111
112
|
def time_zone_support?(relation)
|
112
113
|
if relation.connection.adapter_name =~ /mysql/i
|
113
|
-
|
114
|
+
# need to call klass for Rails < 5.2
|
115
|
+
sql = relation.klass.send(:sanitize_sql_array, ["SELECT CONVERT_TZ(NOW(), '+00:00', ?)", time_zone.tzinfo.name])
|
114
116
|
!relation.connection.select_all(sql).first.values.first.nil?
|
115
117
|
else
|
116
118
|
true
|
@@ -158,7 +158,7 @@ module Groupdate
|
|
158
158
|
end
|
159
159
|
|
160
160
|
tr = sorted_keys.first..sorted_keys.last
|
161
|
-
if options[:current] == false && round_time(now) >= tr.last
|
161
|
+
if options[:current] == false && sorted_keys.any? && round_time(now) >= tr.last
|
162
162
|
tr = tr.first...round_time(now)
|
163
163
|
end
|
164
164
|
tr
|
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.1.
|
4
|
+
version: 4.1.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:
|
11
|
+
date: 2019-05-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -112,16 +112,16 @@ dependencies:
|
|
112
112
|
name: sqlite3
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
114
114
|
requirements:
|
115
|
-
- - "
|
115
|
+
- - "~>"
|
116
116
|
- !ruby/object:Gem::Version
|
117
|
-
version:
|
117
|
+
version: 1.3.0
|
118
118
|
type: :development
|
119
119
|
prerelease: false
|
120
120
|
version_requirements: !ruby/object:Gem::Requirement
|
121
121
|
requirements:
|
122
|
-
- - "
|
122
|
+
- - "~>"
|
123
123
|
- !ruby/object:Gem::Version
|
124
|
-
version:
|
124
|
+
version: 1.3.0
|
125
125
|
description:
|
126
126
|
email: andrew@chartkick.com
|
127
127
|
executables: []
|
@@ -160,8 +160,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
160
160
|
- !ruby/object:Gem::Version
|
161
161
|
version: '0'
|
162
162
|
requirements: []
|
163
|
-
|
164
|
-
rubygems_version: 2.7.6
|
163
|
+
rubygems_version: 3.0.3
|
165
164
|
signing_key:
|
166
165
|
specification_version: 4
|
167
166
|
summary: The simplest way to group temporal data
|