Skip to content

Instantly share code, notes, and snippets.

@camillebaldock
Last active August 29, 2015 14:17
Show Gist options
  • Select an option

  • Save camillebaldock/2aacd5153a15c7def1a3 to your computer and use it in GitHub Desktop.

Select an option

Save camillebaldock/2aacd5153a15c7def1a3 to your computer and use it in GitHub Desktop.
Dashing GitHub issues widget

Description

A Dashing widget for displaying the number of issues opened on a user's repos and on repos of GitHub organisations of your choice.

See a live demo here.

Usage

Setup the following environment variables:

  • GITHUB_TOKEN: Create an application token
  • GITHUB_USER: user for whom you want to track open issues on any repos
  • MONITORED_GITHUB_ORGS: comma-separated list of the names of the GitHub orgs you wish to track open issues for

Dependencies

octokit

Add it to your Dashing application's Gemfile:

gem 'octokit'

and run bundle install.

<li data-row="1" data-col="1" data-sizex="1" data-sizey="1">
<div data-id="issues" data-view="Number" data-title="GitHub Issues" style="background-color:#6E6E6E"></div>
</li>
require 'octokit'
SCHEDULER.every "30m", first_in: 0 do
Octokit.auto_paginate = true
client = Octokit::Client.new(:access_token => ENV["GITHUB_TOKEN"])
number_issues = 0
ENV["MONITORED_GITHUB_ORGS"].split(",").each do |monitored_github_org|
org_repos = client.organization_repositories(monitored_github_org).map { |repo| repo.name }
org_repos.each do |org_repo|
issues = client.issues("#{monitored_github_org}/#{org_repo}", :state => 'open')
number_issues += issues.count
end
end
repos = client.repositories(:user => ENV["GITHUB_USER"])
user_repos = repos.select do |repo|
repo.owner.login == ENV["GITHUB_USER"]
end
user_repos.each do |user_repo|
issues = client.issues(ENV["GITHUB_USER"]+"/"+user_repo.name, :state => 'open')
number_issues += issues.count
end
send_event("issues", { "current" => number_issues })
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment