Created
June 10, 2010 10:04
-
-
Save thenoseman/432783 to your computer and use it in GitHub Desktop.
Batch resolve hoptoad errors
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/Users/fschumac/.rvm/rubies/ree-1.8.7-2010.02/bin/ruby | |
require 'rubygems' | |
require 'active_resource' | |
require 'rest_client' | |
AUTH = "AUTH TOKEN ID" | |
APP = "NAME OF APP" | |
class Hoptoad < ActiveResource::Base | |
self.site = "http://#{APP}.airbrake.io" | |
class << self | |
@@auth_token = AUTH | |
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 | |
errors = Error.find(:all) | |
batch = 1 | |
while errors.length > 0 | |
puts "Resolving batch ##{batch} of #{errors.length} errors ..." | |
errors.each do |error| | |
puts " Resolving Error ##{error.id} '#{error.error_class}', occuring #{error.notices_count} times..." | |
RestClient.put("http://#{APP}.hoptoadapp.com/errors/#{error.id}?auth_token=#{AUTH}", :group => { :resolved => true}) | |
end | |
errors = Error.find(:all) | |
batch += 1 | |
end | |
puts "Nothing left to do" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment