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 +4 -4
- data/README.md +1 -1
- data/VERSION +1 -1
- data/counter_culture.gemspec +2 -2
- data/lib/counter_culture.rb +1 -1
- data/spec/counter_culture_spec.rb +18 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4b1b627a0c744806fbe1214b439f057d504c4056
|
4
|
+
data.tar.gz: 18a273ab383bdad289298b3a6542ffe891ed07ec
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d11550bdb3d9d65e30522ff0a00262dd7259dc725fb0a719c881fdf3d7d3044f335470bb631aa74259e6efaaa824aee6ea00403020ef346f66a8e4e7080ae241
|
7
|
+
data.tar.gz: b8b1a6a4fc8fbd43e82cdff9e2811cb6ca4eb4425fd70cb5bbba1f9eb2c506389bd53c8319311deff0940d1525166e35eab5a49670bb76833d6864762e7f2130
|
data/README.md
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.18
|
data/counter_culture.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "counter_culture"
|
8
|
-
s.version = "0.1.
|
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-
|
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 = [
|
data/lib/counter_culture.rb
CHANGED
@@ -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.
|
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-
|
11
|
+
date: 2013-10-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|