Skip to content

Instantly share code, notes, and snippets.

@danivovich
Created March 1, 2012 02:42
Show Gist options
  • Save danivovich/1946835 to your computer and use it in GitHub Desktop.
Save danivovich/1946835 to your computer and use it in GitHub Desktop.
Count deploys from airbrake
require 'nokogiri'
require 'open-uri'
auth_token = 'AUTH_TOKEN'
site = 'https://ACCOUNT_NAME.airbrake.io/projects/PROJECT_NUMBER'
counts = {
:staging => 0,
:production => 0
}
pages = PAGES_OF_DEPLOYS_FROM_WEB_UI
(1..pages).each do |page|
doc = Nokogiri::XML(open("#{site}/deploys.xml?page=#{page}&auth_token=#{auth_token}"))
counts[:staging] += doc.xpath('//rails-env').map(&:text).count { |e| e == 'staging' }
counts[:production] += doc.xpath('//rails-env').map(&:text).count { |e| e == 'production' }
end
puts "#{counts[:staging]} staging deploys"
puts "#{counts[:production]} production deploys"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment