counter_culture 0.1.17 → 0.1.18

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: 3bf55ab884e9f76030002f56bc3602e3e604d3da
4
- data.tar.gz: e4d81c1554c982ad4990dbecdb26e98996d4d665
3
+ metadata.gz: 4b1b627a0c744806fbe1214b439f057d504c4056
4
+ data.tar.gz: 18a273ab383bdad289298b3a6542ffe891ed07ec
5
5
  SHA512:
6
- metadata.gz: c573939173201d15d2709230b4000401d032cdd684fae5175e6a21e1730461efa7968505757c6147fc13a72a9fc9ff148ea877043f6e5172e20651f9a5273394
7
- data.tar.gz: 0c047ebfc7d0b00b5a0b508d7a37c6ca78588544fa412e48c4418a4df47c6d0dd7c71ab97d062876a1674cc1c4b5ab00990263419d3e8e1cdf4d6b326e245aea
6
+ metadata.gz: d11550bdb3d9d65e30522ff0a00262dd7259dc725fb0a719c881fdf3d7d3044f335470bb631aa74259e6efaaa824aee6ea00403020ef346f66a8e4e7080ae241
7
+ data.tar.gz: b8b1a6a4fc8fbd43e82cdff9e2811cb6ca4eb4425fd70cb5bbba1f9eb2c506389bd53c8319311deff0940d1525166e35eab5a49670bb76833d6864762e7f2130
data/README.md CHANGED
@@ -13,7 +13,7 @@ Turbo-charged counter caches for your Rails app. Huge improvements over the Rail
13
13
  Add counter_culture to your Gemfile:
14
14
 
15
15
  ```ruby
16
- gem 'counter_culture', '~> 0.1.7'
16
+ gem 'counter_culture', '~> 0.1.17'
17
17
  ```
18
18
 
19
19
  Then run ```bundle update ```
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.17
1
+ 0.1.18
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "counter_culture"
8
- s.version = "0.1.17"
8
+ s.version = "0.1.18"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Magnus von Koeller"]
12
- s.date = "2013-10-08"
12
+ s.date = "2013-10-16"
13
13
  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."
14
14
  s.email = "magnus@vonkoeller.de"
15
15
  s.extra_rdoc_files = [
@@ -101,7 +101,7 @@ module CounterCulture
101
101
  # lives in
102
102
  reverse_relation.each do |cur_relation|
103
103
  reflect = relation_reflect(cur_relation)
104
- counts_query = counts_query.joins("JOIN #{reflect.active_record.table_name} ON #{reflect.table_name}.id = #{reflect.active_record.table_name}.#{reflect.foreign_key}")
104
+ counts_query = counts_query.joins("LEFT JOIN #{reflect.active_record.table_name} ON #{reflect.table_name}.id = #{reflect.active_record.table_name}.#{reflect.foreign_key}")
105
105
  end
106
106
 
107
107
  # iterate in batches; otherwise we might run out of memory when there's a lot of
@@ -1065,6 +1065,24 @@ describe "CounterCulture" do
1065
1065
  SimpleMain.find_each { |main| main.simple_dependents_count.should == 3 }
1066
1066
  end
1067
1067
 
1068
+ it "should correctly fix the counter caches when no dependent record exists for some of main records" do
1069
+ # first, clean up
1070
+ SimpleDependent.delete_all
1071
+ SimpleMain.delete_all
1072
+
1073
+ 1000.times do |i|
1074
+ main = SimpleMain.create
1075
+ (main.id % 4).times { main.simple_dependents.create }
1076
+ end
1077
+
1078
+ SimpleMain.find_each { |main| main.simple_dependents_count.should == main.id % 4 }
1079
+
1080
+ SimpleMain.order('random()').limit(50).update_all simple_dependents_count: 1
1081
+ SimpleDependent.counter_culture_fix_counts :batch_size => 100
1082
+
1083
+ SimpleMain.find_each { |main| main.simple_dependents_count.should == main.id % 4 }
1084
+ end
1085
+
1068
1086
  it "should correctly sum up flaot values" do
1069
1087
  user = User.create
1070
1088
 
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.1.17
4
+ version: 0.1.18
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: 2013-10-08 00:00:00.000000000 Z
11
+ date: 2013-10-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails