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

@ -12,7 +12,7 @@ ActiveAdmin.register Channel do
column(:user) { |channel| link_to channel.user.login, admin_user_path(channel.user) if channel.user.present? }
column :public_flag
column :created_at
default_actions
actions
end
form do |f|

View File

@ -12,7 +12,7 @@ ActiveAdmin.register Failedlogin do
column :password
column :ip_address
column :created_at
default_actions
actions
end
end

View File

@ -10,7 +10,7 @@ ActiveAdmin.register Plugin do
column(:user) { |object| link_to object.user.login, admin_user_path(object.user) if object.user.present? }
column :name
column :private_flag
default_actions
actions
end
form do |f|

View File

@ -12,7 +12,7 @@ ActiveAdmin.register User do
column :email
column :login
column :created_at
default_actions
actions
end
show do

View File

@ -164,7 +164,7 @@ class FeedController < ApplicationController
begin
# add a timeout since this query may be really long if there is a lot of data,
# but the last instance of the field is very far back
Timeout::timeout(5) do
Timeout.timeout(5, Timeout::Error) do
# look for a feed where the value isn't null
@feed = Feed.where(:channel_id => @channel.id)
.where("field? is not null", params[:field_id].to_i)

View File

@ -2,7 +2,7 @@ module PagesHelper
def blog_entries
blog = ''
begin
Timeout::timeout(5) do
Timeout.timeout(5, Timeout::Error) do
# get the blog data
blog_url = "http://community.thingspeak.com"
doc = Nokogiri::HTML(open(blog_url, "User-Agent" => "Ruby/#{RUBY_VERSION}").read)

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