counter_culture 0.2.2 → 0.2.3

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
  SHA1:
3
- metadata.gz: 9e66602a56b11c2f0d339149bbae08eea6904c87
4
- data.tar.gz: 5e7bbc39f261492db78d74d1ae81f6cf5d98f824
3
+ metadata.gz: 17e2e8471fc8063fc35d135431aee0c6f9b88945
4
+ data.tar.gz: 3501cf53a5553393f1d23727938f09b8c2007447
5
5
  SHA512:
6
- metadata.gz: be97b621e4e6c783ffa371ba7177af1c529bf7b0238e02a92c2c435cf8ed468ae95a81bdfab2f2a11731ad1fd339e97145beb3ecf1459358b61c879f154d8619
7
- data.tar.gz: 23bd89ddcd5b651a835442f43795b14dcf3afc450e88fb57963663b3ed70a00c7d7739bfd6110347d5b0e468417a0e189df0836303f517f349f894f866f1fe9d
6
+ metadata.gz: e1081eced18d4ef33bb20ea1ceabd0bab38e2deb9a9549dd1610274879739ef48e047fb2d2cdf45ebe7f644a7cc4723e4b8213b4db3b692c0a8c50cad7147fbf
7
+ data.tar.gz: 0cbf2af0334ee313cb789fadb3a38e592fe5f712b5c703d702fac6ae78a55c892ecde74f0108bab0b35c054abe9bed24716fb8621ff961ee27b5f7756159d1ce
@@ -1,3 +1,8 @@
1
+ ## 0.2.3 (October 18, 2016)
2
+
3
+ Improvements:
4
+ - When running `fix_counts` on a table, wrap each batch in a transaction because that is faster on large tables.
5
+
1
6
  ## 0.2.2 (July 11, 2016)
2
7
 
3
8
  Bugfixes:
data/README.md CHANGED
@@ -281,7 +281,7 @@ counter_culture currently does *not* support polymorphic associations. Check [th
281
281
 
282
282
  counter_culture will not update counters in your automated tests *if* you use transactional fixtures. That's because transactional fixtures roll back all your database transactions and they are never committed. But counter_culture will only update its counters in the ```after_commit``` callback, which in this case will never run.
283
283
 
284
- counter_culture itself has extensive automated tests so there should not be a need to test counter caches in your own tests. I therefore recommend removing any checks of counter caches as that will avoid this issue. If that is not an option for you, you can use the [`test_after_commit` gem](https://github.com/grosser/test_after_commit) to trigger `after_commit` callbacks even with transactional fitures enabled. Another option is to turn off transactional fixtures and use something like [database_cleaner](https://github.com/bmabey/database_cleaner) instead to clean your database between tests.
284
+ counter_culture itself has extensive automated tests so there should not be a need to test counter caches in your own tests. I therefore recommend removing any checks of counter caches as that will avoid this issue. If that is not an option for you, you can use the [`test_after_commit` gem](https://github.com/grosser/test_after_commit) to trigger `after_commit` callbacks even with transactional fixtures enabled. Another option is to turn off transactional fixtures and use something like [database_cleaner](https://github.com/bmabey/database_cleaner) instead to clean your database between tests.
285
285
 
286
286
  ## Contributing to counter_culture
287
287
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.2
1
+ 0.2.3
@@ -2,16 +2,16 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
- # stub: counter_culture 0.2.2 ruby lib
5
+ # stub: counter_culture 0.2.3 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "counter_culture"
9
- s.version = "0.2.2"
9
+ s.version = "0.2.3"
10
10
 
11
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
12
  s.require_paths = ["lib"]
13
13
  s.authors = ["Magnus von Koeller"]
14
- s.date = "2016-07-11"
14
+ s.date = "2016-10-18"
15
15
  s.description = "counter_culture provides turbo-charged counter caches that are kept up-to-date not just on create and destroy, that support multiple levels of indirection through relationships, allow dynamic column names and that avoid deadlocks by updating in the after_commit callback."
16
16
  s.email = "magnus@vonkoeller.de"
17
17
  s.extra_rdoc_files = [
@@ -1,5 +1,6 @@
1
1
  require 'after_commit_action'
2
2
  require 'active_support/concern'
3
+ require 'active_support/lazy_load_hooks'
3
4
 
4
5
  require 'counter_culture/extensions'
5
6
  require 'counter_culture/counter'
@@ -1,3 +1,6 @@
1
+ require 'active_support/core_ext/module/delegation'
2
+ require 'active_support/core_ext/module/attribute_accessors'
3
+
1
4
  module CounterCulture
2
5
  class Reconciler
3
6
  attr_reader :counter, :options, :changes
@@ -54,14 +57,16 @@ module CounterCulture
54
57
 
55
58
  counts_query.group(full_primary_key(relation_class)).find_in_batches(batch_size: batch_size) do |records|
56
59
  # now iterate over all the models and see whether their counts are right
57
- records.each do |record|
58
- count = record.read_attribute('count') || 0
59
- next if record.read_attribute(column_name) == count
60
+ ActiveRecord::Base.transaction do
61
+ records.each do |record|
62
+ count = record.read_attribute('count') || 0
63
+ next if record.read_attribute(column_name) == count
60
64
 
61
- track_change(record, column_name, count)
65
+ track_change(record, column_name, count)
62
66
 
63
- # use update_all because it's faster and because a fixed counter-cache shouldn't update the timestamp
64
- relation_class.where(relation_class.primary_key => record.send(relation_class.primary_key)).update_all(column_name => count)
67
+ # use update_all because it's faster and because a fixed counter-cache shouldn't update the timestamp
68
+ relation_class.where(relation_class.primary_key => record.send(relation_class.primary_key)).update_all(column_name => count)
69
+ end
65
70
  end
66
71
  end
67
72
  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: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Magnus von Koeller
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-07-11 00:00:00.000000000 Z
11
+ date: 2016-10-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: after_commit_action