update gems; fix timeout errors

This commit is contained in:
Lee Lawlor
2014-10-06 11:42:02 -04:00
parent 9dca5abadf
commit 3a4906adf1
9 changed files with 141 additions and 96 deletions

View File

@ -36,14 +36,13 @@ class Feed < ActiveRecord::Base
# delete feeds in batches
def self.delete_in_batches(channel_id)
channel = Channel.find(channel_id)
connection = ActiveRecord::Base.connection
# while there are still feeds left
while channel.feeds.count > 0
# create the sql query to delete 1000 feeds from the channel
sql = "DELETE FROM feeds WHERE channel_id=#{channel_id} LIMIT 1000"
# execute the sql query
connection.execute(sql)
ActiveRecord::Base.connection.execute(sql)
# wait a bit before the next delete
sleep 0.1
end