rollups 0.1.0 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +16 -0
- data/LICENSE.txt +1 -1
- data/README.md +2 -0
- data/lib/generators/rollups_generator.rb +9 -1
- data/lib/rollup/aggregator.rb +13 -5
- data/lib/rollup/version.rb +1 -1
- data/lib/rollup.rb +1 -4
- data/lib/rollups.rb +1 -0
- metadata +8 -106
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eb7a00e9ed34a6924e0d6ea7c27fbe96275817274abcc5e0aed4c03edf38f9b2
|
4
|
+
data.tar.gz: cb52591ce2a2f40c173bb925659a7b31812522dd2c81c0906ad2aff80b03f000
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a7a044a8e1b85c51de0043e48381037adb080bded3dbd620fc1dec3715c8cf735a94778470672b269a66e31c764889dbc2d58f02dee7cb542eb739496d36d4c2
|
7
|
+
data.tar.gz: b66ea1e6f81de6bce70d947c816aee005363cdea4e61a1a98cdf4b83714f8b8c814bcba29806436589d6e5ee820f8704267944359341aa20afd84ceda215fb65
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,19 @@
|
|
1
|
+
## 0.1.4 (2021-12-15)
|
2
|
+
|
3
|
+
- Fixed warning with Active Record 7
|
4
|
+
|
5
|
+
## 0.1.3 (2021-10-20)
|
6
|
+
|
7
|
+
- Fixed issue rolling up rollups
|
8
|
+
|
9
|
+
## 0.1.2 (2021-06-07)
|
10
|
+
|
11
|
+
- Fixed deprecation warning with Active Record 6.1
|
12
|
+
|
13
|
+
## 0.1.1 (2020-09-09)
|
14
|
+
|
15
|
+
- Fixed results for earlier versions of MySQL
|
16
|
+
|
1
17
|
## 0.1.0 (2020-09-07)
|
2
18
|
|
3
19
|
- First release
|
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
@@ -4,6 +4,8 @@
|
|
4
4
|
|
5
5
|
Works great with [Ahoy](https://github.com/ankane/ahoy) and [Searchjoy](https://github.com/ankane/searchjoy)
|
6
6
|
|
7
|
+
[![Build Status](https://github.com/ankane/rollup/workflows/build/badge.svg?branch=master)](https://github.com/ankane/rollup/actions)
|
8
|
+
|
7
9
|
## Installation
|
8
10
|
|
9
11
|
Add this line to your application’s Gemfile:
|
@@ -12,7 +12,7 @@ class RollupsGenerator < Rails::Generators::Base
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def migration_source
|
15
|
-
case
|
15
|
+
case adapter
|
16
16
|
when /postg/i
|
17
17
|
"dimensions.rb"
|
18
18
|
else
|
@@ -23,4 +23,12 @@ class RollupsGenerator < Rails::Generators::Base
|
|
23
23
|
def migration_version
|
24
24
|
"[#{ActiveRecord::VERSION::MAJOR}.#{ActiveRecord::VERSION::MINOR}]"
|
25
25
|
end
|
26
|
+
|
27
|
+
def adapter
|
28
|
+
if ActiveRecord::VERSION::STRING.to_f >= 6.1
|
29
|
+
ActiveRecord::Base.connection_db_config.adapter.to_s
|
30
|
+
else
|
31
|
+
ActiveRecord::Base.connection_config[:adapter].to_s
|
32
|
+
end
|
33
|
+
end
|
26
34
|
end
|
data/lib/rollup/aggregator.rb
CHANGED
@@ -35,12 +35,14 @@ class Rollup
|
|
35
35
|
def perform_group(name, column:, interval:, time_zone:, current:, last:, clear:)
|
36
36
|
raise ArgumentError, "Cannot use last and clear together" if last && clear
|
37
37
|
|
38
|
+
time_zone ||= Rollup.time_zone
|
39
|
+
|
38
40
|
gd_options = {
|
39
41
|
current: current
|
40
42
|
}
|
41
43
|
|
42
44
|
# make sure Groupdate global options aren't applied
|
43
|
-
gd_options[:time_zone] = time_zone
|
45
|
+
gd_options[:time_zone] = time_zone
|
44
46
|
gd_options[:week_start] = Rollup.week_start if interval.to_s == "week"
|
45
47
|
gd_options[:day_start] = 0 if Utils.date_interval?(interval)
|
46
48
|
|
@@ -49,8 +51,14 @@ class Rollup
|
|
49
51
|
elsif !clear
|
50
52
|
# if no rollups, compute all intervals
|
51
53
|
# if rollups, recompute last interval
|
52
|
-
max_time = Rollup.where(name: name, interval: interval).maximum(Utils.time_sql(interval))
|
54
|
+
max_time = Rollup.unscoped.where(name: name, interval: interval).maximum(Utils.time_sql(interval))
|
53
55
|
if max_time
|
56
|
+
# for MySQL on Ubuntu 18.04 (and likely other platforms)
|
57
|
+
if max_time.is_a?(String)
|
58
|
+
utc = ActiveSupport::TimeZone["Etc/UTC"]
|
59
|
+
max_time = Utils.date_interval?(interval) ? max_time.to_date : utc.parse(max_time).in_time_zone(time_zone)
|
60
|
+
end
|
61
|
+
|
54
62
|
# aligns perfectly if time zone doesn't change
|
55
63
|
# if time zone does change, there are other problems besides this
|
56
64
|
gd_options[:range] = max_time..
|
@@ -149,7 +157,7 @@ class Rollup
|
|
149
157
|
def maybe_clear(clear, name, interval)
|
150
158
|
if clear
|
151
159
|
Rollup.transaction do
|
152
|
-
Rollup.where(name: name, interval: interval).delete_all
|
160
|
+
Rollup.unscoped.where(name: name, interval: interval).delete_all
|
153
161
|
yield
|
154
162
|
end
|
155
163
|
else
|
@@ -165,10 +173,10 @@ class Rollup
|
|
165
173
|
|
166
174
|
if ActiveRecord::VERSION::MAJOR >= 6
|
167
175
|
options = Utils.mysql? ? {} : {unique_by: conflict_target}
|
168
|
-
Rollup.upsert_all(records, **options)
|
176
|
+
Rollup.unscoped.upsert_all(records, **options)
|
169
177
|
else
|
170
178
|
update = Utils.mysql? ? [:value] : {columns: [:value], conflict_target: conflict_target}
|
171
|
-
Rollup.import(records,
|
179
|
+
Rollup.unscoped.import(records,
|
172
180
|
on_duplicate_key_update: update,
|
173
181
|
validate: false
|
174
182
|
)
|
data/lib/rollup/version.rb
CHANGED
data/lib/rollup.rb
CHANGED
@@ -75,10 +75,7 @@ class Rollup < ActiveRecord::Base
|
|
75
75
|
# feels cleaner than overriding _read_attribute
|
76
76
|
def inspect
|
77
77
|
if Utils.date_interval?(interval)
|
78
|
-
|
79
|
-
previous_time = previous_time.to_s(:db) if previous_time.is_a?(Time)
|
80
|
-
previous_time = previous_time + " 00:00:00" if previous_time.length == 10
|
81
|
-
super.sub("time: \"#{previous_time}\"", "time: \"#{time.to_s(:db)}\"")
|
78
|
+
super.sub(/time: "[^"]+"/, "time: \"#{time.to_formatted_s(:db)}\"")
|
82
79
|
else
|
83
80
|
super
|
84
81
|
end
|
data/lib/rollups.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rollups
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Kane
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-12-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -38,106 +38,8 @@ dependencies:
|
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '5.2'
|
41
|
-
|
42
|
-
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - ">="
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: '0'
|
48
|
-
type: :development
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - ">="
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: '0'
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: rake
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - ">="
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '0'
|
62
|
-
type: :development
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - ">="
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: '0'
|
69
|
-
- !ruby/object:Gem::Dependency
|
70
|
-
name: minitest
|
71
|
-
requirement: !ruby/object:Gem::Requirement
|
72
|
-
requirements:
|
73
|
-
- - ">="
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
version: '5'
|
76
|
-
type: :development
|
77
|
-
prerelease: false
|
78
|
-
version_requirements: !ruby/object:Gem::Requirement
|
79
|
-
requirements:
|
80
|
-
- - ">="
|
81
|
-
- !ruby/object:Gem::Version
|
82
|
-
version: '5'
|
83
|
-
- !ruby/object:Gem::Dependency
|
84
|
-
name: activerecord
|
85
|
-
requirement: !ruby/object:Gem::Requirement
|
86
|
-
requirements:
|
87
|
-
- - ">="
|
88
|
-
- !ruby/object:Gem::Version
|
89
|
-
version: '0'
|
90
|
-
type: :development
|
91
|
-
prerelease: false
|
92
|
-
version_requirements: !ruby/object:Gem::Requirement
|
93
|
-
requirements:
|
94
|
-
- - ">="
|
95
|
-
- !ruby/object:Gem::Version
|
96
|
-
version: '0'
|
97
|
-
- !ruby/object:Gem::Dependency
|
98
|
-
name: pg
|
99
|
-
requirement: !ruby/object:Gem::Requirement
|
100
|
-
requirements:
|
101
|
-
- - ">="
|
102
|
-
- !ruby/object:Gem::Version
|
103
|
-
version: '0'
|
104
|
-
type: :development
|
105
|
-
prerelease: false
|
106
|
-
version_requirements: !ruby/object:Gem::Requirement
|
107
|
-
requirements:
|
108
|
-
- - ">="
|
109
|
-
- !ruby/object:Gem::Version
|
110
|
-
version: '0'
|
111
|
-
- !ruby/object:Gem::Dependency
|
112
|
-
name: mysql2
|
113
|
-
requirement: !ruby/object:Gem::Requirement
|
114
|
-
requirements:
|
115
|
-
- - ">="
|
116
|
-
- !ruby/object:Gem::Version
|
117
|
-
version: '0'
|
118
|
-
type: :development
|
119
|
-
prerelease: false
|
120
|
-
version_requirements: !ruby/object:Gem::Requirement
|
121
|
-
requirements:
|
122
|
-
- - ">="
|
123
|
-
- !ruby/object:Gem::Version
|
124
|
-
version: '0'
|
125
|
-
- !ruby/object:Gem::Dependency
|
126
|
-
name: sqlite3
|
127
|
-
requirement: !ruby/object:Gem::Requirement
|
128
|
-
requirements:
|
129
|
-
- - ">="
|
130
|
-
- !ruby/object:Gem::Version
|
131
|
-
version: '0'
|
132
|
-
type: :development
|
133
|
-
prerelease: false
|
134
|
-
version_requirements: !ruby/object:Gem::Requirement
|
135
|
-
requirements:
|
136
|
-
- - ">="
|
137
|
-
- !ruby/object:Gem::Version
|
138
|
-
version: '0'
|
139
|
-
description:
|
140
|
-
email: andrew@chartkick.com
|
41
|
+
description:
|
42
|
+
email: andrew@ankane.org
|
141
43
|
executables: []
|
142
44
|
extensions: []
|
143
45
|
extra_rdoc_files: []
|
@@ -158,7 +60,7 @@ homepage: https://github.com/ankane/rollup
|
|
158
60
|
licenses:
|
159
61
|
- MIT
|
160
62
|
metadata: {}
|
161
|
-
post_install_message:
|
63
|
+
post_install_message:
|
162
64
|
rdoc_options: []
|
163
65
|
require_paths:
|
164
66
|
- lib
|
@@ -173,8 +75,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
173
75
|
- !ruby/object:Gem::Version
|
174
76
|
version: '0'
|
175
77
|
requirements: []
|
176
|
-
rubygems_version: 3.
|
177
|
-
signing_key:
|
78
|
+
rubygems_version: 3.2.32
|
79
|
+
signing_key:
|
178
80
|
specification_version: 4
|
179
81
|
summary: Rollup time-series data in Rails
|
180
82
|
test_files: []
|