Last active
April 27, 2019 17:44
-
-
Save xdg/7dd1713dda777e95567e to your computer and use it in GitHub Desktop.
This file contains 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
#!/usr/bin/env perl | |
# Copyright 2015 by David Golden | |
# Licensed under CC0 https://creativecommons.org/publicdomain/zero/1.0/ | |
# Updated 2016-03-01: | |
# - more variation in organzations selected; you will want to customize this yourself | |
# - splits out wishlists differently/correctly | |
# - reports only PRs unless --all is specified | |
use v5.10; | |
use strict; | |
use warnings; | |
use utf8; | |
use Carp; | |
use Net::GitHub; | |
use Getopt::Lucid ':all'; | |
use List::Util qw/max/; | |
my $opts = Getopt::Lucid->getopt( | |
[ | |
#<<< No perltidy | |
Switch('all|a'), | |
Switch('ptg'), | |
#>>> | |
] | |
); | |
$opts->validate; | |
sub _git_config { | |
my $key = shift; | |
chomp( my $value = `git config --get $key` ); | |
croak "Unknown $key" unless $value; | |
return $value; | |
} | |
my %WATCHLIST = map { $_ => 1 } qw( | |
CPAN-Common-Index | |
File-Temp | |
Parse-CPAN-Meta | |
Perl-OSType | |
Sub-Uplevel | |
YAML-Tiny | |
); | |
sub _ptg_watched { | |
my $repo = $_[0]{repository}{name}; | |
return 1 if $WATCHLIST{$repo}; | |
return 1 if $repo =~ /^CPAN-Meta/; | |
return; | |
} | |
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; | |
# just xdg issues | |
push @issues, $gh->query("/user/issues?filter=all&state=open"); | |
while ( $gh->has_next_page ) { | |
push @issues, $gh->next_page; | |
} | |
# select org issues | |
for my $org ( qw/dagolden cpan-testers/ ) { | |
push @issues, $gh->query("/orgs/$org/issues?filter=all&state=open"); | |
while ( $gh->has_next_page ) { | |
push @issues, $gh->next_page; | |
} | |
} | |
# select PTG issues | |
if ( $opts->get_ptg ) { | |
push @issues, grep { _ptg_watched($_) } $gh->query("/orgs/Perl-Toolchain-Gang/issues?filter=all&state=open"); | |
while ( $gh->has_next_page ) { | |
push @issues, grep { _ptg_watched($_) } $gh->next_page; | |
} | |
} | |
my %dash; | |
for my $i (@issues) { | |
my $name = $i->{repository}{name}; | |
for (qw/PR wish issue total/) { | |
$dash{ $name }{$_} //= 0; | |
} | |
my $labels = $i->{labels}; | |
my $wishlist = $i->{title} =~ /wish-?list/i | |
|| grep { /enhancement|question|wishlist/i } map { $_->{name} } @{ $i->{labels} }; | |
my $type = | |
exists $i->{pull_request} ? 'PR' | |
: $wishlist ? 'wish' | |
: 'issue'; | |
$dash{ $name }{$type}++; | |
$dash{ $name }{total}++ unless $wishlist; | |
} | |
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) { | |
next unless $opts->get_all || $dash{$k}{PR}; | |
printf( "%*s %3d %3d %3d\n", | |
$width, $k, $dash{$k}{PR}, $dash{$k}{issue}, $dash{$k}{wish}, ); | |
} | |
OK , I was able to fix the problem I was having by using this patch:
diff --git a/github-dashboard b/github-dashboard
index bae5aed..29a97f4 100644
--- a/github-dashboard
+++ b/github-dashboard
@@ -7,7 +7,7 @@ use Carp;
use Net::GitHub;
use List::Util qw/max/;
-my $org = "dagolden";
+my $org = "shlomif";
sub _git_config {
my $key = shift;
@@ -21,7 +21,8 @@ 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");
+# my @issues = $gh->query("/orgs/$org/issues?filter=all&state=open");
+my @issues = $gh->query("/user/issues?filter=all&state=open");
while ( $gh->has_next_page ) {
push @issues, $gh->next_page;
Still it seems like this should be configurable.
@shlomif If you use github.token you don't need user or org. You only need org if you access an org.
I've update the gist to reflect my current iteration of it. Licensed CC0
@xdg : thanks!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Another note is that this code should have an explicit licence and preferably an open source one. And perhaps put it in a normal GitHub repository where people can file issues and pull-requests for it ("shoemaker has no shoes"/etc.).