Skip to content

Instantly share code, notes, and snippets.

@JamesMcMahon
Last active May 24, 2019 21:15
Show Gist options
  • Save JamesMcMahon/7a13d10709705063cbffe46e98efcfe0 to your computer and use it in GitHub Desktop.
Save JamesMcMahon/7a13d10709705063cbffe46e98efcfe0 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
# frozen_string_literal: true
require 'tracker_api'
require 'date'
require 'descriptive_statistics'
def calc_running_velocity(last_3_iterations)
if last_3_iterations.size != 3
return nil
end
last_3_iterations.mean.floor
end
def calc_volatility(last_3_iterations)
if last_3_iterations.size != 3
return nil
end
float_volatility = (last_3_iterations.standard_deviation / last_3_iterations.mean) * 100
if float_volatility.nan?
return 0
end
float_volatility.floor
end
token = ENV['TRACKER_API_TOKEN']
project_id = ENV['TRACKER_PROJECT_ID']
end_date = Date.today
client = TrackerApi::Client.new(token: token)
project = client.project(project_id)
previous_iterations = []
tracker_data = project.iterations(fields: ':default,velocity,accepted_points,effective_points')
.reject {|i| i.start > end_date}
.map do |i|
stories = i.stories.select {|s| s.current_state == 'accepted' and s.story_type != 'release'}
features = stories.select {|s| s.story_type == 'feature'}
last_3_iterations = previous_iterations.take(3).compact.map(&:accepted_points)
attributes = {
start: i.start.to_s,
accepted_points: i.accepted_points,
# effective_points: i.effective_points,
# tracker_velocity: i.velocity,
running_velocity: calc_running_velocity(last_3_iterations),
# team_strength: i.team_strength,
# length: i.length,
volatility: calc_volatility(last_3_iterations),
stories: stories.size,
features: features.size,
chores: stories.select {|s| s.story_type == 'chore'}.size,
bugs: stories.select {|s| s.story_type == 'bug'}.size,
# no_est_delta: i.accepted_points - features.size
}
previous_iterations.unshift(i)
attributes
end
rows = tracker_data.map(&:values)
rows.unshift(tracker_data.first.keys)
csv = rows.map {|r| r.join(',')}
puts csv
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment