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