rollups 0.3.1 → 0.4.0

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
  SHA256:
3
- metadata.gz: b0fa306f943a2bad69a6515e6735374dd1ee4e927e6bd01dfb3b5dc33cd59aa0
4
- data.tar.gz: 8ae83c58992563b5c7b7474c29df74ef45d5450eac7ce4be4280e7ff36712435
3
+ metadata.gz: b9e1a4c50bc160496a4bcc8f4709615dc7f030aa8ac69a02c2ff9ca7221adf94
4
+ data.tar.gz: 271271318f3cc86e79b561fbc0e3ac32160a12cb0a72dfa47de71435a3114a3a
5
5
  SHA512:
6
- metadata.gz: d59d9c091e78af3808e494ff89d9dc0432528a8b69b9c413111a994e7d1fef2718797e23090c885307be2932ea021834fcb25298b173477d9fcad5696148a537
7
- data.tar.gz: ed3bae975a14d4790044097200984c8dd48c28a50023a0e6326c1dd709c117f35f399a8491125fb9eb9c5cf432519e370fc4cdc5c40ec5b4c5da82e0fdf47290
6
+ metadata.gz: 277e0ee40c5f156904547fa3ad92a9faaadeda7c7291426d29b2eb69f5187f80c60a57d83f9a430461a954c02150e3a8f1012a6348dfa8a88d082c5d6c8ffc5a
7
+ data.tar.gz: 37b7ae3c133829ff04bbd06e04789ee94620b98ab3a1bc2c1f812da2cec44aeb2213631e8665c6d919735c8b856a5f548fc893e89874ec6da557e2710fac9f2a
data/CHANGELOG.md CHANGED
@@ -1,3 +1,12 @@
1
+ ## 0.4.0 (2024-10-01)
2
+
3
+ - Added support for Active Record 8
4
+ - Dropped support for Ruby < 3.1 and Active Record < 7
5
+
6
+ ## 0.3.2 (2024-02-09)
7
+
8
+ - Fixed incorrect rollups with `time_zone: false` when `Rollup.time_zone` has a negative UTC offset
9
+
1
10
  ## 0.3.1 (2023-09-20)
2
11
 
3
12
  - Added support for Trilogy
data/LICENSE.txt CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2020-2023 Andrew Kane
3
+ Copyright (c) 2020-2024 Andrew Kane
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
data/README.md CHANGED
@@ -4,7 +4,7 @@
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)
7
+ [![Build Status](https://github.com/ankane/rollup/actions/workflows/build.yml/badge.svg)](https://github.com/ankane/rollup/actions)
8
8
 
9
9
  ## Installation
10
10
 
@@ -14,12 +14,6 @@ Add this line to your application’s Gemfile:
14
14
  gem "rollups"
15
15
  ```
16
16
 
17
- For Rails < 6, also add:
18
-
19
- ```ruby
20
- gem "activerecord-import"
21
- ```
22
-
23
17
  And run:
24
18
 
25
19
  ```sh
@@ -29,7 +29,7 @@ class Rollup
29
29
  def validate_column(column)
30
30
  unless column.is_a?(Symbol) || column.is_a?(Arel::Nodes::SqlLiteral)
31
31
  column = column.to_s
32
- unless /\A\w+(\.\w+)?\z/i.match(column)
32
+ unless /\A\w+(\.\w+)?\z/i.match?(column)
33
33
  raise ActiveRecord::UnknownAttributeReference, "Query method called with non-attribute argument(s): #{column.inspect}. Use Arel.sql() for known-safe values."
34
34
  end
35
35
  end
@@ -43,7 +43,7 @@ class Rollup
43
43
  raise ArgumentError, "Cannot use range and current together" if range && !current.nil?
44
44
 
45
45
  current = true if current.nil?
46
- time_zone ||= Rollup.time_zone
46
+ time_zone = Rollup.time_zone if time_zone.nil?
47
47
 
48
48
  gd_options = {
49
49
  current: current
@@ -68,7 +68,14 @@ class Rollup
68
68
  # for MySQL on Ubuntu 18.04 (and likely other platforms)
69
69
  if max_time.is_a?(String)
70
70
  utc = ActiveSupport::TimeZone["Etc/UTC"]
71
- max_time = Utils.date_interval?(interval) ? max_time.to_date : utc.parse(max_time).in_time_zone(time_zone)
71
+ max_time =
72
+ if Utils.date_interval?(interval)
73
+ max_time.to_date
74
+ else
75
+ t = utc.parse(max_time)
76
+ t = t.in_time_zone(time_zone) if time_zone
77
+ t
78
+ end
72
79
  end
73
80
 
74
81
  # aligns perfectly if time zone doesn't change
@@ -112,9 +119,9 @@ class Rollup
112
119
 
113
120
  # removing starting and ending quotes
114
121
  # for simplicity, they don't need to be the same
115
- value = value[1..-2] if value.match(/\A["'`].+["'`]\z/)
122
+ value = value[1..-2] if value.match?(/\A["'`].+["'`]\z/)
116
123
 
117
- unless value.match(/\A\w+\z/)
124
+ unless value.match?(/\A\w+\z/)
118
125
  raise "Cannot determine dimension name: #{group}. Use the dimension_names option"
119
126
  end
120
127
 
@@ -184,6 +191,12 @@ class Rollup
184
191
  conflict_target << :dimensions if Utils.dimensions_supported?
185
192
 
186
193
  options = Utils.mysql? ? {} : {unique_by: conflict_target}
194
+ if ActiveRecord::VERSION::MAJOR >= 8
195
+ utc = ActiveSupport::TimeZone["Etc/UTC"]
196
+ records.each do |v|
197
+ v[:time] = v[:time].in_time_zone(utc) if v[:time].is_a?(Date)
198
+ end
199
+ end
187
200
  Rollup.unscoped.upsert_all(records, **options)
188
201
  end
189
202
  end
@@ -1,5 +1,5 @@
1
1
  class Rollup
2
2
  # not used in gemspec to avoid superclass mismatch
3
3
  # be sure to update there as well
4
- VERSION = "0.3.1"
4
+ VERSION = "0.4.0"
5
5
  end
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.3.1
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Kane
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-09-21 00:00:00.000000000 Z
11
+ date: 2024-10-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '6.1'
19
+ version: '7'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: '6.1'
26
+ version: '7'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: groupdate
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -68,14 +68,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
68
68
  requirements:
69
69
  - - ">="
70
70
  - !ruby/object:Gem::Version
71
- version: '3'
71
+ version: '3.1'
72
72
  required_rubygems_version: !ruby/object:Gem::Requirement
73
73
  requirements:
74
74
  - - ">="
75
75
  - !ruby/object:Gem::Version
76
76
  version: '0'
77
77
  requirements: []
78
- rubygems_version: 3.4.10
78
+ rubygems_version: 3.5.16
79
79
  signing_key:
80
80
  specification_version: 4
81
81
  summary: Rollup time-series data in Rails