counter_culture 2.6.2 → 2.7.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: aa2c63a1888a7dd52c62d2f8e3680e1e3f78833fb40fced5ad47feb93c1e15f3
4
- data.tar.gz: 72b10a0d6c9a130b81b183aec2bcd53d190e497d8fd32e9fb212ae545d68e655
3
+ metadata.gz: 74fff95505913ba522b3ec93bc9101c375c7de5678744145a0e4959f2c267361
4
+ data.tar.gz: bc284f87da6f949e7d875b7f30c43accbe23ce5716601af9fc4143eb6346954d
5
5
  SHA512:
6
- metadata.gz: a5c8ab72cd34d55394b0b62a588913df03fd8a939137667b18f47841cc103833c19ae811e20d10dd49df07acd79ac61c1c2ce1fb3df6386849c234d46a4ccc1f
7
- data.tar.gz: 9157a71361ffc1cf0f40acfff1840f55ebdc485e13f6765428395612f14e3b07c8fa17077623baa191456e7e2cf359546990d00c0958b21277fe158d03a24e20
6
+ metadata.gz: e63708745c4ffbb727a1b4da61a0d027de76d7256ee5d9669fa0f18dfcc2b183f26ddc109f45d6af6fb68a79c040e73872f647e8453c7b801e390036601878eb
7
+ data.tar.gz: c58c36d4aaf450450d913ad93487c7012de5de0ba8bb4f99c83a3994b64e8aed19f04a0d62c0df21ceda862312b9c010af042857709d891f746e20403ef893f2
@@ -1,3 +1,8 @@
1
+ ## 2.7.0 (November 16, 2020)
2
+
3
+ Improvements:
4
+ - New `column_name` option for `counter_culture_fix_counts` (#300)
5
+
1
6
  ## 2.6.2 (October 21, 2020)
2
7
 
3
8
  Improvements:
data/README.md CHANGED
@@ -270,6 +270,10 @@ Product.counter_culture_fix_counts only: :category
270
270
  Product.counter_culture_fix_counts only: [[:subcategory, :category]]
271
271
  # will automatically fix counts only on the two-level [:subcategory, :category] relation on Product
272
272
 
273
+ Product.counter_culture_fix_counts column_name: :reviews_count
274
+ # will automatically fix counts only on the :reviews_count column on Product
275
+ # This allows us to skip the columns that have already been processed. This is useful after running big DB changes that affect only one counter cache column.
276
+
273
277
  # :except and :only also accept arrays
274
278
 
275
279
  Product.counter_culture_fix_counts verbose: true
@@ -59,7 +59,8 @@ module CounterCulture
59
59
  #
60
60
  # options:
61
61
  # { :exclude => list of relations to skip when fixing counts,
62
- # :only => only these relations will have their counts fixed }
62
+ # :only => only these relations will have their counts fixed,
63
+ # :column_name => only this column will have its count fixed }
63
64
  # returns: a list of fixed record as an array of hashes of the form:
64
65
  # { :entity => which model the count was fixed on,
65
66
  # :id => the id of the model that had the incorrect count,
@@ -79,7 +80,7 @@ module CounterCulture
79
80
  next if options[:exclude] && options[:exclude].include?(counter.relation)
80
81
  next if options[:only] && !options[:only].include?(counter.relation)
81
82
 
82
- reconciler_options = %i(batch_size finish skip_unsupported start touch verbose where)
83
+ reconciler_options = %i(batch_size column_name finish skip_unsupported start touch verbose where)
83
84
 
84
85
  reconciler = CounterCulture::Reconciler.new(counter, options.slice(*reconciler_options))
85
86
  reconciler.reconcile!
@@ -76,6 +76,10 @@ module CounterCulture
76
76
 
77
77
  counter_column_names = column_names || {nil => counter_cache_name}
78
78
 
79
+ if options[:column_name]
80
+ counter_column_names = counter_column_names.select{ |_, v| options[:column_name].to_s == v }
81
+ end
82
+
79
83
  # iterate over all the possible counter cache column names
80
84
  counter_column_names.each do |where, column_name|
81
85
  # if the column name is nil, that means those records don't affect
@@ -1,3 +1,3 @@
1
1
  module CounterCulture
2
- VERSION = '2.6.2'.freeze
2
+ VERSION = '2.7.0'.freeze
3
3
  end
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: 2.6.2
4
+ version: 2.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Magnus von Koeller
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-10-21 00:00:00.000000000 Z
11
+ date: 2020-11-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -275,7 +275,7 @@ homepage: https://github.com/magnusvk/counter_culture
275
275
  licenses:
276
276
  - MIT
277
277
  metadata: {}
278
- post_install_message:
278
+ post_install_message:
279
279
  rdoc_options: []
280
280
  require_paths:
281
281
  - lib
@@ -290,8 +290,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
290
290
  - !ruby/object:Gem::Version
291
291
  version: '0'
292
292
  requirements: []
293
- rubygems_version: 3.1.2
294
- signing_key:
293
+ rubygems_version: 3.1.4
294
+ signing_key:
295
295
  specification_version: 4
296
296
  summary: Turbo-charged counter caches for your Rails app.
297
297
  test_files: []