activerecord-slotted_counters 0.1.1 → 0.1.2
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 94aead1f1be073e3dbf7548257d6db2b8eda15be09f2c199b6b3cdbf9b6ba0f3
|
4
|
+
data.tar.gz: ac2e1b977ab04501cd1139bd1d410b9f58b0b9395add905b1034eebb54fe4c86
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ba74654e981dbc83043dc295296939e85053b2c7c8543ca3472d2f659523b9a3ea5be60ac15a87a492f7fa3758defac451382ff518a96f4feee573eb0f68ed26
|
7
|
+
data.tar.gz: 857ec7de346c584b1fcdd79bcb81becb7ecec9bb86b2087a8acf83d25ed13b55d25883439b6242b3f26bd726cc592897930ff9f1755c720b7aca41ed55d91503
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,10 @@
|
|
2
2
|
|
3
3
|
## master
|
4
4
|
|
5
|
+
## 0.1.2 (2023-03-28)
|
6
|
+
|
7
|
+
- Fix preloading counters for multiple records [#12](https://github.com/evilmartians/activerecord-slotted_counters/pull/12) ([@LukinEgor][])
|
8
|
+
|
5
9
|
## 0.1.1 (2023-01-17)
|
6
10
|
|
7
11
|
- Fix prevent double increment/decrement of native counter caches [#10](https://github.com/evilmartians/activerecord-slotted_counters/pull/10) ([@danielwestendorf][])
|
@@ -5,8 +5,8 @@ require "activerecord_slotted_counters/utils"
|
|
5
5
|
|
6
6
|
module ActiveRecordSlottedCounters
|
7
7
|
class SlottedCounter < ::ActiveRecord::Base
|
8
|
-
scope :associated_records, ->(counter_name,
|
9
|
-
where(counter_name: counter_name,
|
8
|
+
scope :associated_records, ->(counter_name, klass) do
|
9
|
+
where(counter_name: counter_name, associated_record_type: klass)
|
10
10
|
end
|
11
11
|
end
|
12
12
|
|
@@ -38,7 +38,7 @@ module ActiveRecordSlottedCounters
|
|
38
38
|
counter_name = slotted_counter_name(counter_type)
|
39
39
|
association_name = slotted_counter_association_name(counter_type)
|
40
40
|
|
41
|
-
has_many association_name, ->(model) { associated_records(counter_name, model.
|
41
|
+
has_many association_name, ->(model) { associated_records(counter_name, model.class.to_s) }, **SLOTTED_COUNTERS_ASSOCIATION_OPTIONS
|
42
42
|
|
43
43
|
scope :with_slotted_counters, ->(counter_type) do
|
44
44
|
association_name = slotted_counter_association_name(counter_type)
|
@@ -191,16 +191,8 @@ module ActiveRecordSlottedCounters
|
|
191
191
|
|
192
192
|
def read_slotted_counter(counter_type)
|
193
193
|
association_name = slotted_counter_association_name(counter_type)
|
194
|
-
|
195
|
-
|
196
|
-
scope = association(association_name).scope
|
197
|
-
counter = scope.sum(&:count)
|
198
|
-
|
199
|
-
return counter
|
200
|
-
end
|
201
|
-
|
202
|
-
scope = send(association_name)
|
203
|
-
scope.sum(:count)
|
194
|
+
scope = association(association_name).load_target
|
195
|
+
scope.sum(&:count)
|
204
196
|
end
|
205
197
|
end
|
206
198
|
end
|
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activerecord-slotted_counters
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Egor Lukin
|
8
8
|
- Vladimir Dementyev
|
9
|
-
autorequire:
|
9
|
+
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2023-
|
12
|
+
date: 2023-04-19 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activerecord
|
@@ -95,6 +95,20 @@ dependencies:
|
|
95
95
|
- - ">="
|
96
96
|
- !ruby/object:Gem::Version
|
97
97
|
version: '0'
|
98
|
+
- !ruby/object:Gem::Dependency
|
99
|
+
name: rspec-sqlimit
|
100
|
+
requirement: !ruby/object:Gem::Requirement
|
101
|
+
requirements:
|
102
|
+
- - ">="
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
version: '0'
|
105
|
+
type: :development
|
106
|
+
prerelease: false
|
107
|
+
version_requirements: !ruby/object:Gem::Requirement
|
108
|
+
requirements:
|
109
|
+
- - ">="
|
110
|
+
- !ruby/object:Gem::Version
|
111
|
+
version: '0'
|
98
112
|
description: Active Record slotted counters support
|
99
113
|
email:
|
100
114
|
- dementiev.vm@gmail.com
|
@@ -121,7 +135,7 @@ metadata:
|
|
121
135
|
documentation_uri: http://github.com/evilmartians/activerecord-slotted_counters
|
122
136
|
homepage_uri: http://github.com/evilmartians/activerecord-slotted_counters
|
123
137
|
source_code_uri: http://github.com/evilmartians/activerecord-slotted_counters
|
124
|
-
post_install_message:
|
138
|
+
post_install_message:
|
125
139
|
rdoc_options: []
|
126
140
|
require_paths:
|
127
141
|
- lib
|
@@ -136,8 +150,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
136
150
|
- !ruby/object:Gem::Version
|
137
151
|
version: '0'
|
138
152
|
requirements: []
|
139
|
-
rubygems_version: 3.3.
|
140
|
-
signing_key:
|
153
|
+
rubygems_version: 3.3.3
|
154
|
+
signing_key:
|
141
155
|
specification_version: 4
|
142
156
|
summary: Active Record slotted counters support
|
143
157
|
test_files: []
|