- 
      
- 
        Save marcus/6015881 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' | |
| 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 | 
| // ---------------------------------------------------------------------------- | |
| // 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> | |
| ... | 
I was able to hardcode my API Token and Project ID as follows ...
PivotalTracker::Client.token = 'INSERT HERE'
@project = PivotalTracker::Project.find(875681)
... but it says 0 points for each category (finished, started, unstarted, total), which does not seem right. It correctly reports the velocity so it seems like I have it hooked up correctly.
Any advice or diagnostic I can run to further test?
https://gist.github.com/TigerWolf/6604732
This should fix your problems and give you an alternative to add the settings.
pivotal.yml file:
---
pivotal_api_token: XXXXXXXXXXXXXX
pivotal_project_id: XXXX
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:inblock (2 levels) in <top (required)>'
/vagrant/jobs/pivotal.rb:100:in each' /vagrant/jobs/pivotal.rb:100:inreduce'
/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:incall'
/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:inblock 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:inrun_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:inrun'
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:indispatch'
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'
    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"}

how do i define the pivotal_api_token and pivotal_project_id methods?