Created
October 25, 2011 21:34
-
-
Save shoe/1314383 to your computer and use it in GitHub Desktop.
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
require 'rubygems' | |
require 'mechanize' | |
agent = Mechanize.new | |
login = "https://#{subdomain}.airbrake.io/login" | |
page = agent.get(login) | |
# login | |
page.form.field_with(:id => "session_email").value = email | |
page.form.field_with(:id => "session_password").value = password | |
page.form.submit | |
# collect error links on all pages | |
root = "https://#{subdomain}.airbrake.io/projects/#{project_id}/errors" | |
errors_page = root | |
bug_links = [] | |
while errors_page | |
page = agent.get(errors_page) | |
links = page.root.css("tr.unresolved td strong a") | |
puts "found #{links.length} error links" | |
bug_links.concat(links) | |
next_page_link = page.root.css("a.next_page").first | |
errors_page = next_page_link && next_page_link.attributes["href"] | |
end | |
# process each error | |
bug_links.each {|link| | |
bug_page = agent.click(link) | |
unresolved = bug_page.root.css(".resolved#resolved_toggle").empty? | |
removed = bug_page.root.text =~ /Some information on the occurrence of this error has been removed from the database/ | |
href = link.attributes['href'].value | |
if removed | |
if unresolved | |
puts "resolving #{href}" | |
bug_page.form.field_with(:name =>"group[resolved]").value = "1" | |
bug_page.form.submit | |
else | |
puts "#{href} already resolved" | |
end | |
else | |
puts "#{href} still present" | |
end | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment