effective_developer 0.8.4 → 0.8.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/models/effective/content_replacer.rb +11 -2
- data/lib/effective_developer/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 19ed54abb37c597e55d1b45aef357c4174881f79243d25edaf7ab0d540c121a1
|
4
|
+
data.tar.gz: 1179ac079bd24741a518040211600f84f68965e48f230920e1d5812d2ba6d98e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 31ffc32f164d5c76772dce297f257a8e11b397b565b4cf201b9df3d642d107e1f61352f73b8724954ee7834639529bcbc3f28c549f155bfac196073800564e40
|
7
|
+
data.tar.gz: ff8a97d65972d97b2ad5418217c827511e5342915d2b4df6ef73cb1c7a2f49503c51dda34d397d8f56124089d52b1dff5b055036c95f78a31312d81f3eafd438
|
@@ -16,11 +16,14 @@ module Effective
|
|
16
16
|
def replace!(old_value, new_value)
|
17
17
|
raise("old_value cannot contain a \' character") if old_value.include?("'")
|
18
18
|
raise("new_value cannot contain a \' character") if new_value.include?("'")
|
19
|
+
|
20
|
+
total = 0
|
19
21
|
|
20
22
|
places.each do |table, columns|
|
21
23
|
columns.each do |column|
|
22
24
|
sql = "SELECT COUNT(*) FROM #{table} WHERE #{column} ILIKE '%#{old_value}%'"
|
23
25
|
existing = ActiveRecord::Base.connection.execute(sql).first['count'].to_i
|
26
|
+
total += existing
|
24
27
|
|
25
28
|
puts "Replacing #{existing} occurrences of #{old_value} with #{new_value} in #{table}.#{column}"
|
26
29
|
|
@@ -28,22 +31,28 @@ module Effective
|
|
28
31
|
ActiveRecord::Base.connection.execute(sql)
|
29
32
|
end
|
30
33
|
end
|
31
|
-
|
32
|
-
|
34
|
+
|
35
|
+
total
|
33
36
|
end
|
34
37
|
|
35
38
|
def count(old_value)
|
36
39
|
raise("old_value cannot contain a \' character") if old_value.include?("'")
|
37
40
|
|
41
|
+
total = 0
|
42
|
+
|
38
43
|
places.each do |table, columns|
|
39
44
|
columns.each do |column|
|
40
45
|
sql = "SELECT COUNT(*) FROM #{table} WHERE #{column} ILIKE '%#{old_value}%'"
|
41
46
|
existing = ActiveRecord::Base.connection.execute(sql).first['count'].to_i
|
47
|
+
total += existing
|
42
48
|
|
43
49
|
puts "There are #{existing} occurrences of #{old_value} in #{table}.#{column}"
|
44
50
|
end
|
45
51
|
end
|
52
|
+
|
53
|
+
total
|
46
54
|
end
|
55
|
+
alias_method :find, :count
|
47
56
|
|
48
57
|
end
|
49
58
|
end
|