Created
March 16, 2009 21:20
-
-
Save eric/80084 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
#!/usr/bin/env ruby | |
require 'httparty' | |
require 'active_support' | |
class Tender | |
include HTTParty | |
format :json | |
def initialize(hostname, u, p) | |
@base_uri = HTTParty.normalize_base_uri(hostname) | |
@auth = {:username => u, :password => p} | |
end | |
def open_issues | |
get '/dashboard/open.json' | |
end | |
def new_issues | |
get '/dashboard/new.json' | |
end | |
def pending_issues | |
get '/dashboard/pending.json' | |
end | |
def ticketed_issues | |
get '/dashboard/assigned.json' | |
end | |
def resolved_issues | |
get '/dashboard/resolved.json' | |
end | |
def all_discussions | |
discussions = [] | |
discussions += open_issues['discussions'] | |
discussions += new_issues['discussions'] | |
discussions += pending_issues['discussions'] | |
discussions += ticketed_issues['discussions'] | |
discussions += resolved_issues['discussions'] | |
discussions.uniq | |
end | |
def get(path, options = {}) | |
self.class.get(path, options.merge(:basic_auth => @auth, :base_uri => @base_uri)) | |
end | |
end | |
t = Tender.new(ARGV[0], ARGV[1], ARGV[2]) | |
discussions = t.all_discussions | |
discussions = discussions.group_by { |d| d['created_at'].to_date } | |
discussions = discussions.sort_by { |d| d.first } | |
labels = [] | |
data = [] | |
discussions.each do |date, ds| | |
labels << date | |
data << ds.length | |
puts "#{date}: #{ds.length}" | |
end | |
# If you want to chart it | |
require 'gchart' | |
puts Gchart.sparkline(:data => data, :size => '200x25') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment