Skip to content

Instantly share code, notes, and snippets.

@danivovich
Created Oct 11, 2011
Embed
What would you like to do?
Pivotal feature points by label
require 'pivotal-tracker'
TOKEN = 'API_TOKEN'
PROJECT_NUM = -1
def estimate_to_hours(estimate)
2 ** estimate
end
PivotalTracker::Client.token = TOKEN
project = PivotalTracker::Project.find(PROJECT_NUM)
label_data = {}
unestimated = []
stories = project.stories.all(:story_type => ['feature'])
stories.each do |story|
if story.estimate == -1 || story.estimate == nil
unestimated << "#{story.id} #{story.name}"
next
end
next unless story.current_state == 'unstarted' || story.current_state == 'unscheduled'
labels = story.labels.split(',') rescue ['NO LABEL']
labels.each do |label|
label_data[label] ||= {}
label_data[label][story.estimate] ||= 0
label_data[label][story.estimate] += 1
label_data[label]['TOTAL'] ||= 0
label_data[label]['TOTAL'] += story.estimate
label_data[label]['HOURS'] ||= 0
label_data[label]['HOURS'] += estimate_to_hours(story.estimate)
end
end
sorted_labels = label_data.keys.sort
sorted_labels.each do |label|
data = label_data[label]
puts label
puts " #{data['TOTAL']} points"
puts " 0 points : #{data[0] || 0}"
puts " 1 point : #{data[1] || 0}"
puts " 2 points : #{data[2] || 0}"
puts " 3 points : #{data[3] || 0}"
puts " #{data['HOURS']} hours\n\n"
end
unestimated.each do |unestimated_story|
puts "Story #{unestimated_story} is not estimated"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment