[noosfero/noosfero][master] fix-yaml-migration: use find_each to reduce memory consumption

Rodrigo Souto gitlab at gitlab.com
Thu Mar 26 11:41:22 BRT 2015


Rodrigo Souto pushed to master at Noosfero / noosfero


Commits:
a3c427e8 by Rodrigo Souto at 2015-03-26T11:41:21Z
fix-yaml-migration: use find_each to reduce memory consumption

- - - - -


1 changed file:

- db/migrate/20140724134601_fix_yaml_encoding.rb


Changes:

=====================================
db/migrate/20140724134601_fix_yaml_encoding.rb
=====================================
--- a/db/migrate/20140724134601_fix_yaml_encoding.rb
+++ b/db/migrate/20140724134601_fix_yaml_encoding.rb
@@ -18,9 +18,8 @@ class FixYamlEncoding < ActiveRecord::Migration
   private
 
   def self.fix_encoding(model, param)
-    result = model.all
-    puts "Fixing #{result.count} rows of #{model} (#{param})"
-    result.each do |r|
+    puts "Fixing #{model.count} rows of #{model} (#{param})"
+    model.find_each do |r|
       begin
         yaml = r.send(param)
         # if deserialization failed then a string is returned


View it on GitLab: https://gitlab.com/noosfero/noosfero/commit/a3c427e81661ae172e790a19dcee188b592a4b3d
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listas.softwarelivre.org/pipermail/noosfero-dev/attachments/20150326/d90616f8/attachment.html>


More information about the Noosfero-dev mailing list