Skip to content

Instantly share code, notes, and snippets.

@pauldruziak
Created February 14, 2011 09:31
Show Gist options
  • Select an option

  • Save pauldruziak/825662 to your computer and use it in GitHub Desktop.

Select an option

Save pauldruziak/825662 to your computer and use it in GitHub Desktop.
Generating the status update report for pivotaltracker.
token: your token for pivotaltracker
require 'rubygems'
require 'pivotal-tracker'
require 'yaml'
# patch for pivotal-tracker gem
module PivotalTracker
class Activity
def self.encode_options(options)
return nil if !options.is_a?(Hash) || options.empty?
options_string = []
options_string << "limit=#{options.delete(:limit)}" if options[:limit]
options_string << "newer_than_version=#{options.delete(:newer_than_version)}" if options[:newer_than_version]
if options[:occurred_since]
options_string << "occurred_since_date=#{options[:occurred_since].utc}"
elsif options[:occurred_since_date]
options_string << "occurred_since_date=#{options[:occurred_since_date]}"
end
return "?#{URI.escape(options_string.join('&'))}"
end
end
end
APP_CONFIG = YAML.load_file("config.yml")
PivotalTracker::Client.token = APP_CONFIG['token']
activities = PivotalTracker::Activity.all(nil, :limit => 100, :occurred_since_date => Time.now.strftime("%Y/%m/%d 00:00:00 UTC"))
states = activities.keep_if do |a|
a.event_type == 'story_update' && !a.description.include?("edited")
end.group_by do |a|
a.stories[0].id
end.group_by do |id, activities|
activities.first.stories.first.current_state
end
{"accepted" => "Ready for production", "delivered" => "Deployed to staging", "finished" => "Done", "rejected" => [], "started" => "In progress"}.each do |state, title|
if states.include?(state)
puts title.upcase
states[state].each do |id, activities|
puts " " + activities.first.description.match(/\".+\"/)[0]
activities.each do |activity|
puts " " + activity.description.match(/^[\w ]+/)[0] + "(#{activity.occurred_at.strftime("%H:%M")})"
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment