counter_culture 3.5.0 → 3.5.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.circleci/config.yml +25 -7
- data/Appraisals +1 -0
- data/CHANGELOG.md +10 -0
- data/README.md +5 -3
- data/gemfiles/rails_7.1.gemfile +7 -0
- data/lib/counter_culture/counter.rb +5 -3
- data/lib/counter_culture/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9cb364451d9ed9870da702f56a916db61dd29792766ace4732eb915ef7e1d0fd
|
4
|
+
data.tar.gz: 547fe6bfa9068ff65f5fa48a3afe1a847956ab04150a97f316f147c510c6bba3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 910b10128b0d1fab9145f12d77262cd007e0cfe3d6730d0d6e0606e4e4fa59de59822ad690211fe6563604bfdb7fe3f9d68cd10d9419c6b9b01c823f0eb6a307
|
7
|
+
data.tar.gz: 611498966bc1a81b6177909ccae783cc9c4e598337aaeb02eb9db3586c06748ce02e555c6f357a5cb4c63a73fad902d52e321f9f0e8af6212c776c7d6a9a9150
|
data/.circleci/config.yml
CHANGED
@@ -48,8 +48,8 @@ workflows:
|
|
48
48
|
- test:
|
49
49
|
matrix:
|
50
50
|
parameters:
|
51
|
-
ruby-version: ["2.6", "2.7", "3.0", "3.1", "3.2"]
|
52
|
-
rails-version: ["5.2", "6.0", "6.1", "7.0"]
|
51
|
+
ruby-version: ["2.6", "2.7", "3.0", "3.1", "3.2", "3.3"]
|
52
|
+
rails-version: ["5.2", "6.0", "6.1", "7.0", "7.1"]
|
53
53
|
database: ["postgresql", "sqlite3", "mysql2"]
|
54
54
|
exclude:
|
55
55
|
- ruby-version: "3.0"
|
@@ -57,28 +57,37 @@ workflows:
|
|
57
57
|
database: "postgresql"
|
58
58
|
- ruby-version: "3.0"
|
59
59
|
rails-version: "5.2"
|
60
|
-
database: "
|
60
|
+
database: "mysql2"
|
61
61
|
- ruby-version: "3.0"
|
62
62
|
rails-version: "5.2"
|
63
|
-
database: "
|
63
|
+
database: "sqlite3"
|
64
64
|
- ruby-version: "3.1"
|
65
65
|
rails-version: "5.2"
|
66
66
|
database: "postgresql"
|
67
|
+
- ruby-version: "3.1"
|
68
|
+
rails-version: "5.2"
|
69
|
+
database: "mysql2"
|
67
70
|
- ruby-version: "3.1"
|
68
71
|
rails-version: "5.2"
|
69
72
|
database: "sqlite3"
|
70
73
|
- ruby-version: "3.2"
|
71
74
|
rails-version: "5.2"
|
72
|
-
database: "
|
75
|
+
database: "postgresql"
|
73
76
|
- ruby-version: "3.2"
|
74
77
|
rails-version: "5.2"
|
75
|
-
database: "
|
78
|
+
database: "mysql2"
|
76
79
|
- ruby-version: "3.2"
|
77
80
|
rails-version: "5.2"
|
78
81
|
database: "sqlite3"
|
79
|
-
- ruby-version: "3.
|
82
|
+
- ruby-version: "3.3"
|
83
|
+
rails-version: "5.2"
|
84
|
+
database: "postgresql"
|
85
|
+
- ruby-version: "3.3"
|
80
86
|
rails-version: "5.2"
|
81
87
|
database: "mysql2"
|
88
|
+
- ruby-version: "3.3"
|
89
|
+
rails-version: "5.2"
|
90
|
+
database: "sqlite3"
|
82
91
|
- ruby-version: "2.6"
|
83
92
|
rails-version: "7.0"
|
84
93
|
database: "postgresql"
|
@@ -88,3 +97,12 @@ workflows:
|
|
88
97
|
- ruby-version: "2.6"
|
89
98
|
rails-version: "7.0"
|
90
99
|
database: "mysql2"
|
100
|
+
- ruby-version: "2.6"
|
101
|
+
rails-version: "7.1"
|
102
|
+
database: "postgresql"
|
103
|
+
- ruby-version: "2.6"
|
104
|
+
rails-version: "7.1"
|
105
|
+
database: "sqlite3"
|
106
|
+
- ruby-version: "2.6"
|
107
|
+
rails-version: "7.1"
|
108
|
+
database: "mysql2"
|
data/Appraisals
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,13 @@
|
|
1
|
+
## 3.5.2 (January 16, 2024)
|
2
|
+
|
3
|
+
Bugfixes:
|
4
|
+
- Assign attributes to the duped model on a lower level when determining whether a model has changed to avoid invoking unrelated callbacks (#386)
|
5
|
+
|
6
|
+
## 3.5.1 (January 8, 2024)
|
7
|
+
|
8
|
+
Bugfixes:
|
9
|
+
- Fix touching for counted models without `updated_at` (#383)
|
10
|
+
|
1
11
|
## 3.5.0 (August 25, 2023)
|
2
12
|
|
3
13
|
Improvements:
|
data/README.md
CHANGED
@@ -7,7 +7,7 @@ Turbo-charged counter caches for your Rails app. Huge improvements over the Rail
|
|
7
7
|
* Supports dynamic column names, making it possible to split up the counter cache for different types of objects
|
8
8
|
* Can keep a running count, or a running total
|
9
9
|
|
10
|
-
Tested against Ruby 2.6, 2.7, 3.0, 3.1 and 3.
|
10
|
+
Tested against Ruby 2.6, 2.7, 3.0, 3.1, 3.2 and 3.3 and against the latest patch releases of Rails 5.2, 6.0, 6.1, 7.0 and 7.1.
|
11
11
|
|
12
12
|
Please note that -- unlike Rails' built-in counter-caches -- counter_culture does not currently change the behavior of the `.size` method on ActiveRecord associations. If you want to avoid a database query and read the cached value, please use the attribute name containing the counter cache directly.
|
13
13
|
|
@@ -74,7 +74,7 @@ class Group < ActiveRecord::Base
|
|
74
74
|
has_many :members, through: :group_memberships, class: "User"
|
75
75
|
end
|
76
76
|
|
77
|
-
class
|
77
|
+
class GroupMembership < ActiveRecord::Base
|
78
78
|
belongs_to :group
|
79
79
|
belongs_to :member, class: "User"
|
80
80
|
counter_culture :group, column_name: "members_count"
|
@@ -358,6 +358,8 @@ Product.counter_culture_fix_counts touch: 'category_count_changed'
|
|
358
358
|
|
359
359
|
The options start and finish are especially useful if you want multiple workers dealing with the same processing queue. You can make worker 1 handle all the records between id 1 and 9999 and worker 2 handle from 10000 and beyond by setting the :start and :finish option on each worker.
|
360
360
|
|
361
|
+
> **! NOTE**: the IDs we pass as `start` and `finish` here are in fact `Category` IDs, not `Product`!
|
362
|
+
|
361
363
|
```ruby
|
362
364
|
Product.counter_culture_fix_counts start: 10_000
|
363
365
|
# will fix counts for all counter caches defined on Product from record 10000 and onwards.
|
@@ -374,7 +376,7 @@ Product.counter_culture_fix_counts start: 2001, finish: 3000
|
|
374
376
|
|
375
377
|
#### Fix counter cache using a replica database
|
376
378
|
|
377
|
-
When fixing counter caches the number of reads usually vastly exceeds the number of writes. It can make sense to offload the
|
379
|
+
When fixing counter caches the number of reads usually vastly exceeds the number of writes. It can make sense to offload the read load to a replica database in this case. Rails 6 introduced [native handling of multiple database connections](https://guides.rubyonrails.org/v6.0/active_record_multiple_databases.html). You can use this to send read traffic to a read-only replica using the option `db_connection_builder`:
|
378
380
|
|
379
381
|
```ruby
|
380
382
|
Product.counter_culture_fix_counts db_connection_builder: proc{|reading, block|
|
@@ -81,8 +81,8 @@ module CounterCulture
|
|
81
81
|
end
|
82
82
|
# and here we update the timestamp, if so desired
|
83
83
|
if touch
|
84
|
-
current_time =
|
85
|
-
timestamp_columns =
|
84
|
+
current_time = klass.send(:current_time_from_proper_timezone)
|
85
|
+
timestamp_columns = klass.send(:timestamp_attributes_for_update_in_model)
|
86
86
|
if touch != true
|
87
87
|
# starting in Rails 6 this is frozen
|
88
88
|
timestamp_columns = timestamp_columns.dup
|
@@ -314,7 +314,9 @@ module CounterCulture
|
|
314
314
|
changes_method = ACTIVE_RECORD_VERSION >= Gem::Version.new("5.1.0") ? :saved_changes : :changed_attributes
|
315
315
|
obj.public_send(changes_method).each do |key, value|
|
316
316
|
old_value = ACTIVE_RECORD_VERSION >= Gem::Version.new("5.1.0") ? value.first : value
|
317
|
-
|
317
|
+
# We set old values straight to AR @attributes variable to avoid
|
318
|
+
# write_attribute callbacks from other gems (e.g. ArTransactionChanges)
|
319
|
+
prev.instance_variable_get(:@attributes).write_from_user(key, old_value)
|
318
320
|
end
|
319
321
|
|
320
322
|
prev
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: counter_culture
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.5.
|
4
|
+
version: 3.5.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Magnus von Koeller
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-01-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -317,6 +317,7 @@ files:
|
|
317
317
|
- gemfiles/rails_6.0.gemfile
|
318
318
|
- gemfiles/rails_6.1.gemfile
|
319
319
|
- gemfiles/rails_7.0.gemfile
|
320
|
+
- gemfiles/rails_7.1.gemfile
|
320
321
|
- lib/counter_culture.rb
|
321
322
|
- lib/counter_culture/counter.rb
|
322
323
|
- lib/counter_culture/extensions.rb
|