Skip to content

Instantly share code, notes, and snippets.

@tomlea
Created December 3, 2009 00:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tomlea/247776 to your computer and use it in GitHub Desktop.
Save tomlea/247776 to your computer and use it in GitHub Desktop.
# Really hacky script to mark all hoptoad errors as resolved.
require 'active_resource'
require 'net/http'
ACCOUNT="your-account-name"
AUTH_TOKEN='your-auth-token'
class Hoptoad < ActiveResource::Base
self.site = "http://#{ACCOUNT}.hoptoadapp.com"
class << self
def find(*arguments)
arguments = append_auth_token_to_params(*arguments)
super(*arguments)
end
def append_auth_token_to_params(*arguments)
opts = arguments.last.is_a?(Hash) ? arguments.pop : {}
opts = opts.has_key?(:params) ? opts : opts.merge(:params => {})
opts[:params] = opts[:params].merge(:auth_token => AUTH_TOKEN)
arguments << opts
arguments
end
end
end
class Error < Hoptoad
end
queue = Queue.new
10.times do
Thread.new do
Net::HTTP.start("#{ACCOUNT}.hoptoadapp.com", 80) do |client|
while error_id = queue.pop
req = Net::HTTP::Put.new("/errors/#{error_id}.xml?auth_token=#{AUTH_TOKEN}")
req.set_form_data("group[resolved]" => true)
client.request(req)
puts error_id
end
end
end
end
done = Set.new
while errors = Error.find( :all ) and errors.any?
sleep 1 if errors.map(&:id).reject(&done.method(:include?)).each(&queue.method(:<<)).each(&done.method(:<<)).empty?
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment