Skip to content

Instantly share code, notes, and snippets.

@TigerWolf
Forked from marcus/Apreview.md
Last active April 6, 2016 17:48
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save TigerWolf/6604732 to your computer and use it in GitHub Desktop.
Save TigerWolf/6604732 to your computer and use it in GitHub Desktop.
[...]
# This version of the gem has a fix for the stories relationship nested in iterations
# https://github.com/averell23/pivotal-tracker/commit/9040620cfde32024ae9ba2554e44feaadf7a2496
gem 'pivotal-tracker', :git => 'git://github.com/averell23/pivotal-tracker'
[...]
class Dashing.Pivotal extends Dashing.Widget
<h1>
<span class="title" data-bind="title"></span>
<span data-bind="iteration_start"></span> -
<span data-bind="iteration_finish"></span>
</h1>
<div id="pivotal_stories">
<div class="stats_row">
<div class="finished_container container">
<div class="section_title"><span data-bind="finished"></span> Finished</div>
<span class="points" data-bind="finished_estimate"></span> pts
</div>
<div class="started_container container">
<div class="section_title"><span data-bind="started"></span> Started</div>
<span class="points" data-bind="started_estimate"></span> pts
</div>
<div class="unstarted_container container">
<div class="section_title"> <span data-bind="unstarted"></span> Unstarted</div>
<span class="points" data-bind="unstarted_estimate"></span> pts
</div>
<div class="total_container container">
<div class="section_title"><span data-bind="total"></span> Total</div>
<span class="points" data-bind="total_estimate"></span> pts
</div>
</div>
<div style="clear:both;"></div>
<div class="velocity_row">
<div class="velocity_container">Velocity: <span data-bind="velocity"></span></div>
</div>
</div>
require 'pivotal-tracker'
config_file = File.dirname(File.expand_path(__FILE__)) + '/../config/pivotal.yml'
config = YAML::load(File.open(config_file))
PivotalTracker::Client.token = config['pivotal_api_token']
@project = PivotalTracker::Project.find config['pivotal_project_id']
date_format = '%b %d'
SCHEDULER.every '10m', :first_in => 0 do
if @project.is_a?(PivotalTracker::Project)
@iteration = PivotalTracker::Iteration.current(@project)
# Velocity
velocity = @project.current_velocity
# Finished stories in the current iteration
finished_stories = @iteration.stories.select{|s|s.current_state == "finished"}
finished_count = finished_stories.length
finished_estimate = finished_stories.reduce(0){|sum, s| sum + (s.estimate || 0)}
# Started stories in the current iteration
started_stories = @iteration.stories.select{|s|s.current_state == "started"}
started_count = started_stories.length
started_estimate = started_stories.reduce(0){|sum, s| sum + (s.estimate || 0)}
# Unstarted
unstarted_stories = @iteration.stories.select{|s|s.current_state == "unstarted"}
unstarted_count = unstarted_stories.length
unstarted_estimate = unstarted_stories.reduce(0){|sum, s| sum + (s.estimate || 0)}
# All stories in the current iteration
total_stories = finished_count + started_count + unstarted_count
total_estimate = finished_estimate + started_estimate + unstarted_estimate
send_event 'pivotal', {velocity: velocity,
iteration_start: @iteration.start.strftime(date_format),
iteration_finish: @iteration.finish.strftime(date_format),
unstarted: unstarted_count,
unstarted_estimate: unstarted_estimate,
started: started_count,
started_estimate: started_estimate,
finished: finished_count,
finished_estimate: finished_estimate,
total: total_stories,
total_estimate: total_estimate
}
else
puts 'Not a Pivotal project'
end
end
// ----------------------------------------------------------------------------
// Sass declarations
// ----------------------------------------------------------------------------
$background-color: rgb(135, 193, 230);
.widget-pivotal {
background-color: $background-color;
font-size: 30px;
.section_title {
font-size: 27px;
}
.points {
font-size: 40px;
}
.velocity_row {
padding-top: 15px;
}
.container {
float: left;
width: 25%;
padding-bottom: 40px;
padding-top: 40px;
}
.unstarted_container {
background-color: red;
}
.started_container {
background-color: #d8c600;
}
.finished_container {
background-color: green;
}
.total_container {
background-color: black;
}
}
...
<li data-row="2" data-col="1" data-sizex="2" data-sizey="1">
<div data-id="pivotal" data-view="Pivotal" data-title="Pivotal Stories" data-moreinfo="" data-prefix=""></div>
</li>
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment