Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save wadewilliams/f6e5e0354c3fb61fb910 to your computer and use it in GitHub Desktop.
Save wadewilliams/f6e5e0354c3fb61fb910 to your computer and use it in GitHub Desktop.
<% content_for :title do %>1080p dashboard<% end %>
<div class="gridster">
<ul>
<li data-row="1" data-col="1" data-sizex="2" data-sizey="1">
<div data-id="git_issues_labeled_defects" data-view="Graph" data-title="Defect Count" ></div>
</li>
</ul>
</div>
#!/usr/bin/env ruby
require 'rest-client'
require 'json'
require 'date'
git_token = "YOUR-KEY-HERE"
git_owner = "OWNER"
git_project = "REPO"
git_issue_label = "LABELS,TO,TRACK"
## Change this if you want to run more than one set of issue widgets
event_name = "git_issues_labeled_defects"
## the endpoint we'll be hitting
uri = "https://api.github.com/repos/#{git_owner}/#{git_project}/issues?state=open&labels=#{git_issue_label}&per_page=100&access_token=#{git_token}"
## Create an array to hold our data points
points = []
## One hours worth of data for, seed 60 empty points (rickshaw acts funny if you don't).
(0..60).each do |a|
points << { x: a, y: 0.01 }
end
## Grab the last x value
last_x = points.last[:x]
SCHEDULER.every '1m', :first_in => 0 do |job|
puts "Getting #{uri}"
response = RestClient.get uri
issues = JSON.parse(response.body, symbolize_names: true)
current_defects = issues.length
## Drop the first point value and increment x by 1
points.shift
last_x += 1
## Push the most recent point value
points << { x: last_x, y: current_defects }
send_event(event_name, {
text: current_defects, points:points
})
end # SCHEDULER

Demo: http://dashing-github-issues.herokuapp.com/

This will give you a way to display a Dashing graph widget with a sub-set of github issues. Built on top of the graph widget and jwalton's github milestone widget.

To use:

  • Add the following to your gemfile:

  •   gem 'rest-client'
    
  • Replace the git_token, git_owner, git_project, and git_issue_label in git-issues.rb as appropriate.

License

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment