I have a method on my model that looks like this. def self.itunes_update # don''t run it if it''s already running if Setting.first.update_lock? puts "updates locked" # it''s not running right now so run it else all_apps = self.all all_apps.each do |app| # do stuff with each app end # job done, clear the lock end end It works fine, but it processes 10,000 records and takes about an hour to run on heroku. I originally just had a rake task calling it every 3 hours but heroku were SIGTERMing it and suggested that I move it to delayed_job, which I have done like this.. App.delay.itunes_update it''s working fine. They do however suggest that I process this in batches or smaller chunks. How would I do that, and does that sound like a good idea? Also - do I need to do the locking any more, I think delayed job handles it for me - that said, guess it doesn''t do any harm? best bb -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
anyone done anything like this before? -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
bingo bob wrote in post #989039:> anyone done anything like this before?What if you select 100 records per pass in an oldest-update == first-selected order? model.Find(:all, :order => "updated_at DESC", :limit => 100) -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
I''m not sure this is what you mean, but I use a daemon for anything that would make the browser respond slowly. I have a table "delayed_tasks" and the controller just writes a row to that table and finishes. Then the daemon looks for rows in the table and handles them behind the scenes and deletes them when handled. For instance, I do that for sending email because it takes a number of seconds for email to get delivered. If it is something the user is waiting for, the browser can periodically do an ajax call to see if the results are ready. On Thu, Mar 24, 2011 at 12:31 PM, Ar Chron <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> bingo bob wrote in post #989039: >> anyone done anything like this before? > > What if you select 100 records per pass in an oldest-update => first-selected order? > > model.Find(:all, :order => "updated_at DESC", :limit => 100) > > -- > Posted via http://www.ruby-forum.com/. > > -- > You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en. > >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.