Skip to content

Instantly share code, notes, and snippets.

@shlomif
Forked from xdg/github-dashboard
Created February 8, 2016 08:47
Show Gist options
  • Save shlomif/f693d02b781739420dc8 to your computer and use it in GitHub Desktop.
Save shlomif/f693d02b781739420dc8 to your computer and use it in GitHub Desktop.
#!/usr/bin/env perl
use v5.10;
use strict;
use warnings;
use utf8;
use Carp;
use Net::GitHub;
use List::Util qw/max/;
my $org = "dagolden";
sub _git_config {
my $key = shift;
chomp( my $value = `git config --get $key` );
croak "Unknown $key" unless $value;
return $value;
}
my $github_user = _git_config("github.user");
my $github_token = _git_config("github.token");
my $gh = Net::GitHub->new( access_token => $github_token );
my @issues = $gh->query("/orgs/$org/issues?filter=all&state=open");
while ( $gh->has_next_page ) {
push @issues, $gh->next_page;
}
my %dash;
for my $i (@issues) {
for (qw/PR wish issue/) {
$dash{ $i->{repository}{name} }{$_} //= 0;
}
my $wishlist = grep { /wish-?list/i } $i->{title}, @{ $i->{labels} };
my $type =
exists $i->{pull_request} ? 'PR'
: $wishlist ? 'wish'
: 'issue';
$dash{ $i->{repository}{name} }{$type}++;
}
my $width = max( map { length($_) } keys %dash );
my @sorted = sort {
$dash{$b}{PR} <=> $dash{$a}{PR}
|| $dash{$b}{issue} <=> $dash{$a}{issue}
|| lc($a) cmp lc($b)
} keys %dash;
for my $k (@sorted) {
printf( "%*s %3d %3d %3d\n",
$width, $k, $dash{$k}{PR}, $dash{$k}{issue}, $dash{$k}{wish}, );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment