Last active
February 4, 2019 16:35
-
-
Save marcus/6015881 to your computer and use it in GitHub Desktop.
Pivotal Tracker Iteration Status widget for Dashing
This file contains hidden or 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
[...] | |
# 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' | |
� | |
[...] |
This file contains hidden or 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
class Dashing.Pivotal extends Dashing.Widget |
This file contains hidden or 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
<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> |
This file contains hidden or 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
require 'pivotal-tracker' | |
PivotalTracker::Client.token = settings.pivotal_api_token | |
@project = PivotalTracker::Project.find settings.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 |
This file contains hidden or 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
// ---------------------------------------------------------------------------- | |
// 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; | |
} | |
} |
This file contains hidden or 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
... | |
<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> | |
... |
The Releases inside an iteration don't have estimated points causing a nil exception at somatory, I added a
started_stories = @iteration.stories.select{|s|s.current_state == "started" and s.story_type != "release"}
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I tried using this gem out-of-the-box and I got the error below - What do you suggest I try?:
scheduler caught exception:
nil can't be coerced into Fixnum
/vagrant/jobs/pivotal.rb:100:in
+' /vagrant/jobs/pivotal.rb:100:in
block (2 levels) in <top (required)>'/vagrant/jobs/pivotal.rb:100:in
each' /vagrant/jobs/pivotal.rb:100:in
reduce'/vagrant/jobs/pivotal.rb:100:in
block in <top (required)>' /home/vagrant/.rvm/gems/ruby-2.1.1/gems/rufus-scheduler-2.0.24/lib/rufus/sc/jobs.rb:230:in
call'/home/vagrant/.rvm/gems/ruby-2.1.1/gems/rufus-scheduler-2.0.24/lib/rufus/sc/jobs.rb:230:in
trigger_block' /home/vagrant/.rvm/gems/ruby-2.1.1/gems/rufus-scheduler-2.0.24/lib/rufus/sc/jobs.rb:204:in
block in trigger'/home/vagrant/.rvm/gems/ruby-2.1.1/gems/rufus-scheduler-2.0.24/lib/rufus/sc/scheduler.rb:430:in `call'
/home/vagrant/.rvm/gems/ruby-2.1.1/gems/rufus-scheduler-2.0.24/lib/rufus/sc/scheduler.rb:430:in `block in trigger_job'
^C/home/vagrant/.rvm/gems/ruby-2.1.1/gems/dashing-1.3.4/lib/dashing/cli.rb:89:in
'system': Interrupt from /home/vagrant/.rvm/gems/ruby-2.1.1/gems/dashing-1.3.4/lib/dashing/cli.rb:89:in
run_command'from /home/vagrant/.rvm/gems/ruby-2.1.1/gems/dashing-1.3.4/lib/dashing/cli.rb:64:in
start' from /home/vagrant/.rvm/gems/ruby-2.1.1/gems/thor-0.18.1/lib/thor/command.rb:27:in
run'from /home/vagrant/.rvm/gems/ruby-2.1.1/gems/thor-0.18.1/lib/thor/invocation.rb:120:in
invoke_command' from /home/vagrant/.rvm/gems/ruby-2.1.1/gems/thor-0.18.1/lib/thor.rb:363:in
dispatch'from /home/vagrant/.rvm/gems/ruby-2.1.1/gems/thor-0.18.1/lib/thor/base.rb:439:in
start' from /home/vagrant/.rvm/gems/ruby-2.1.1/gems/dashing-1.3.4/bin/dashing:9:in
<top (required)>'from /home/vagrant/.rvm/gems/ruby-2.1.1/bin/dashing:23:in
load' from /home/vagrant/.rvm/gems/ruby-2.1.1/bin/dashing:23:in
from /home/vagrant/.rvm/gems/ruby-2.1.1/bin/ruby_executable_hooks:15:in
eval' from /home/vagrant/.rvm/gems/ruby-2.1.1/bin/ruby_executable_hooks:15:in
'