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

@ -1,24 +1,23 @@
GIT
remote: git://github.com/gregbell/active_admin.git
revision: d11c0a56504a378d04a96a656ed1a545e9f165a7
revision: 0c83cfe0b9b43a4a27a63c13f27d6682b0ff6cae
specs:
activeadmin (1.0.0.pre)
arbre (~> 1.0)
arbre (~> 1.0, >= 1.0.2)
bourbon
coffee-rails
devise (~> 3.2)
formtastic (~> 2.3.0.rc3)
inherited_resources (~> 1.3)
formtastic (~> 3.0)
inherited_resources (~> 1.4.1)
jquery-rails
jquery-ui-rails
jquery-ui-rails (~> 5.0)
kaminari (~> 0.15)
rails (>= 3.2, < 4.2)
ransack (~> 1.0)
ransack (~> 1.3)
sass-rails
GIT
remote: git://github.com/moomerman/twitter_oauth.git
revision: 04e6bbfe635a376cae342d234214cdab864fe797
revision: 712430503037b144d8dffb2f4964b485d51485a8
specs:
twitter_oauth (0.4.94)
json (>= 1.8.0)
@ -34,7 +33,7 @@ GIT
GEM
remote: http://rubygems.org/
specs:
ZenTest (4.9.5)
ZenTest (4.11.0)
actionmailer (4.0.5)
actionpack (= 4.0.5)
mail (~> 2.5.4)
@ -61,15 +60,15 @@ GEM
multi_json (~> 1.3)
thread_safe (~> 0.1)
tzinfo (~> 0.3.37)
acts_as_list (0.3.0)
acts_as_list (0.4.0)
activerecord (>= 3.0)
acts_as_tree (1.5.0)
acts_as_tree (2.1.0)
activerecord (>= 3.0.0)
addressable (2.3.5)
annotate (2.6.1)
addressable (2.3.6)
annotate (2.6.5)
activerecord (>= 2.3.0)
rake (>= 0.8.7)
arbre (1.0.1)
arbre (1.0.2)
activesupport (>= 3.0.0)
arel (4.0.2)
autotest (4.4.6)
@ -77,37 +76,37 @@ GEM
autotest-rails (4.2.1)
ZenTest (~> 4.5)
bcrypt (3.1.7)
bcrypt-ruby (3.1.5)
bcrypt (>= 3.1.3)
bourbon (3.2.1)
bourbon (3.2.3)
sass (~> 3.2)
thor
buftok (0.2.0)
builder (3.1.4)
capistrano (2.15.4)
capistrano (2.15.5)
highline
net-scp (>= 1.0.0)
net-sftp (>= 2.0.0)
net-ssh (>= 2.0.14)
net-ssh-gateway (>= 1.1.0)
chronic (0.10.2)
clockwork (0.7.7)
clockwork (1.0.0)
activesupport
tzinfo
coffee-rails (4.0.1)
coffee-script (>= 2.2.0)
railties (>= 4.0.0, < 5.0)
coffee-script (2.2.0)
coffee-script (2.3.0)
coffee-script-source
execjs
coffee-script-source (1.6.3)
cookiejar (0.3.0)
coffee-script-source (1.8.0)
cookiejar (0.3.2)
daemons (1.1.9)
dalli (2.7.0)
dalli (2.7.2)
database_cleaner (1.2.0)
devise (3.2.3)
bcrypt-ruby (~> 3.0)
devise (3.4.0)
bcrypt (~> 3.0)
orm_adapter (~> 0.1)
railties (>= 3.2.6, < 5)
responders
thread_safe (~> 0.1)
warden (~> 1.2.3)
diff-lcs (1.2.5)
@ -124,40 +123,44 @@ GEM
http_parser.rb (>= 0.6.0)
em-socksify (0.3.0)
eventmachine (>= 1.0.0.beta.4)
em-twitter (0.3.2)
em-twitter (0.3.3)
buftok (~> 0.2)
eventmachine (~> 1.0)
http_parser.rb (~> 0.6)
simple_oauth (~> 0.2)
equalizer (0.0.9)
erubis (2.7.0)
eventmachine (1.0.3)
exception_notification (4.0.1)
actionmailer (>= 3.0.4)
activesupport (>= 3.0.4)
execjs (2.0.2)
factory_girl (4.3.0)
execjs (2.2.1)
factory_girl (4.4.0)
activesupport (>= 3.0.0)
factory_girl_rails (4.3.0)
factory_girl (~> 4.3.0)
factory_girl_rails (4.4.1)
factory_girl (~> 4.4.0)
railties (>= 3.0.0)
faker (1.2.0)
faker (1.4.3)
i18n (~> 0.5)
faraday (0.8.9)
multipart-post (~> 1.2.0)
formtastic (2.3.0.rc3)
actionpack (>= 3.0)
geokit (1.8.4)
faraday (0.9.0)
multipart-post (>= 1.2, < 3)
formtastic (3.0.0)
actionpack (>= 3.2.13)
geokit (1.9.0)
multi_json (>= 1.3.2)
geokit-rails (2.0.1)
geokit (~> 1.5)
rails (>= 3.0)
gravatarify (3.1.0)
gravatarify (3.1.1)
has_scope (0.6.0.rc)
actionpack (>= 3.2, < 5)
activesupport (>= 3.2, < 5)
highline (1.6.20)
highline (1.6.21)
hike (1.2.3)
http (0.6.2)
http_parser.rb (~> 0.6.0)
http_parser.rb (0.6.0)
i18n (0.6.9)
i18n (0.6.11)
i18n-tasks (0.5.4)
activesupport
easy_translate (>= 0.5.0)
@ -172,54 +175,57 @@ GEM
jquery-rails (3.0.4)
railties (>= 3.0, < 5.0)
thor (>= 0.14, < 2.0)
jquery-ui-rails (4.2.1)
jquery-ui-rails (5.0.0)
railties (>= 3.2.16)
json (1.8.1)
json_spec (1.1.1)
json_spec (1.1.2)
multi_json (~> 1.0)
rspec (~> 2.0)
kaminari (0.15.1)
rspec (>= 2.0, < 4.0)
kaminari (0.16.1)
actionpack (>= 3.0.0)
activesupport (>= 3.0.0)
kgio (2.8.1)
libv8 (3.16.14.3)
kgio (2.9.2)
libv8 (3.16.14.7)
mail (2.5.4)
mime-types (~> 1.16)
treetop (~> 1.4.8)
memoizable (0.4.2)
thread_safe (~> 0.3, >= 0.3.1)
mime-types (1.25.1)
mini_portile (0.5.2)
mini_portile (0.6.0)
minitest (4.7.5)
mono_logger (1.1.0)
multi_json (1.10.0)
multipart-post (1.2.0)
multi_json (1.10.1)
multipart-post (2.0.0)
mysql2 (0.3.16)
naught (1.0.0)
nested_form (0.3.2)
net-scp (1.1.2)
net-scp (1.2.1)
net-ssh (>= 2.6.5)
net-sftp (2.1.2)
net-ssh (>= 2.6.5)
net-ssh (2.7.0)
net-ssh (2.9.1)
net-ssh-gateway (1.2.0)
net-ssh (>= 2.6.5)
newrelic_rpm (3.7.1.182)
nokogiri (1.6.1)
mini_portile (~> 0.5.0)
newrelic_rpm (3.9.5.251)
nokogiri (1.6.3.1)
mini_portile (= 0.6.0)
non-stupid-digest-assets (1.0.4)
oauth (0.4.7)
orm_adapter (0.5.0)
polyamorous (1.0.0)
polyamorous (1.1.0)
activerecord (>= 3.0)
polyglot (0.3.4)
puma (2.8.1)
polyglot (0.3.5)
puma (2.9.1)
rack (>= 1.1, < 2.0)
quiet_assets (1.0.2)
quiet_assets (1.0.3)
railties (>= 3.1, < 5.0)
rack (1.5.2)
rack-protection (1.5.2)
rack-protection (1.5.3)
rack
rack-test (0.6.2)
rack (>= 1.0)
rack-utf8_sanitizer (1.1.0)
rack-utf8_sanitizer (1.2.2)
rack (~> 1.0)
rails (4.0.5)
actionmailer (= 4.0.5)
@ -229,7 +235,7 @@ GEM
bundler (>= 1.3.0, < 2.0)
railties (= 4.0.5)
sprockets-rails (~> 2.0.0)
rails_autolink (1.1.5)
rails_autolink (1.1.6)
rails (> 3.1)
railties (4.0.5)
actionpack (= 4.0.5)
@ -237,22 +243,22 @@ GEM
rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0)
rake (10.3.2)
ransack (1.2.3)
ransack (1.4.1)
actionpack (>= 3.0)
activerecord (>= 3.0)
activesupport (>= 3.0)
i18n
polyamorous (~> 1.0.0)
redis (3.0.7)
redis-namespace (1.4.1)
redis (~> 3.0.4)
polyamorous (~> 1.1)
redis (3.1.0)
redis-namespace (1.5.1)
redis (~> 3.0, >= 3.0.4)
ref (1.0.5)
responders (1.0.0)
railties (>= 3.2, < 5)
resque (1.25.1)
resque (1.25.2)
mono_logger (~> 1.0)
multi_json (~> 1.0)
redis-namespace (~> 1.2)
redis-namespace (~> 1.3)
sinatra (>= 0.9.2)
vegas (~> 0.1.2)
resque-scheduler (2.3.1)
@ -263,11 +269,11 @@ GEM
rspec-core (~> 2.14.0)
rspec-expectations (~> 2.14.0)
rspec-mocks (~> 2.14.0)
rspec-core (2.14.7)
rspec-expectations (2.14.4)
rspec-core (2.14.8)
rspec-expectations (2.14.5)
diff-lcs (>= 1.1.3, < 2.0)
rspec-mocks (2.14.4)
rspec-rails (2.14.1)
rspec-mocks (2.14.6)
rspec-rails (2.14.2)
actionpack (>= 3.0)
activemodel (>= 3.0)
activesupport (>= 3.0)
@ -284,11 +290,11 @@ GEM
sprockets (~> 2.8, <= 2.11.0)
sprockets-rails (~> 2.0.0)
simple_oauth (0.2.0)
sinatra (1.4.4)
sinatra (1.4.5)
rack (~> 1.4)
rack-protection (~> 1.4)
tilt (~> 1.3, >= 1.3.4)
slop (3.5.0)
slop (3.6.0)
spork (0.9.2)
sprockets (2.11.0)
hike (~> 1.2)
@ -299,38 +305,45 @@ GEM
actionpack (>= 3.0)
activesupport (>= 3.0)
sprockets (~> 2.8)
sqlite3 (1.3.8)
sqlite3 (1.3.9)
sqlite3-ruby (1.3.3)
sqlite3 (>= 1.3.3)
term-ansicolor (1.3.0)
tins (~> 1.0)
terminal-table (1.4.5)
therubyracer (0.12.0)
therubyracer (0.12.1)
libv8 (~> 3.16.14.0)
ref
thor (0.19.1)
thread (0.1.4)
thread_safe (0.3.3)
thread_safe (0.3.4)
tilt (1.4.1)
tins (1.3.0)
tins (1.3.3)
treetop (1.4.15)
polyglot
polyglot (>= 0.3.1)
turbolinks (2.2.2)
turbolinks (2.4.0)
coffee-rails
tweetstream (2.6.0)
tweetstream (2.6.1)
daemons (~> 1.1)
em-http-request (>= 1.1.1)
em-twitter (~> 0.3)
multi_json (~> 1.3)
twitter (~> 4.8)
twitter (4.8.1)
faraday (~> 0.8, < 0.10)
multi_json (~> 1.0)
simple_oauth (~> 0.2)
tzinfo (0.3.39)
tzinfo-data (1.2013.9)
uglifier (2.4.0)
twitter (~> 5.5)
twitter (5.11.0)
addressable (~> 2.3)
buftok (~> 0.2.0)
equalizer (~> 0.0.9)
faraday (~> 0.9.0)
http (~> 0.6.0)
http_parser.rb (~> 0.6.0)
json (~> 1.8)
memoizable (~> 0.4.0)
naught (~> 1.0)
simple_oauth (~> 0.2.0)
tzinfo (0.3.41)
tzinfo-data (1.2013.8)
uglifier (2.5.3)
execjs (>= 0.3.0)
json (>= 1.8.0)
vegas (0.1.11)
@ -341,7 +354,7 @@ GEM
nokogiri (>= 1.2.0)
rack (>= 1.0)
rack-test (>= 0.5.3)
will_paginate (3.0.5)
will_paginate (3.0.7)
will_paginate-bootstrap (1.0.1)
will_paginate (>= 3.0.3)

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

33
spec/models/feed_spec.rb Normal file
View File

@ -0,0 +1,33 @@
require 'spec_helper'
describe Feed do
it "should close the connection when an exception is raised" do
# use a single connection for both queries
connection = ActiveRecord::Base.connection
# cause a proper timeout with the second argument to timeout()
begin
Timeout.timeout(1, Timeout::Error) do
connection.execute("SELECT sleep(2)")
end
rescue Timeout::Error => e
rescue => e
end
# capture the error message
error_message = nil
begin
connection.execute("SELECT 1")
rescue => e
error_message = e.message
end
error_message.should eq("Mysql2::Error: closed MySQL connection: SELECT 1")
# check the connection back in afterwards
ActiveRecord::Base.connection_pool.checkin(connection)
end
end