Skip to content

Commit 212a070

Browse files
committed
add a github issues graphing script
1 parent e15358f commit 212a070

1 file changed

Lines changed: 104 additions & 0 deletions

File tree

‎scripts/issues-no-state.pl‎

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
#!/usr/bin/env perl
2+
3+
use warnings;
4+
use strict;
5+
6+
use Net::GitHub;
7+
use DateTime;
8+
use DateTime::Format::ISO8601;
9+
10+
my $gh = Net::GitHub->new(
11+
login => 'ara4n', pass => 'secret'
12+
);
13+
14+
$gh->set_default_user_repo('vector-im', 'vector-web');
15+
16+
my @issues = $gh->issue->repos_issues({ state => 'all', milestone => 3 });
17+
while ($gh->issue->has_next_page) {
18+
push @issues, $gh->issue->next_page;
19+
}
20+
21+
# we want:
22+
# day by day:
23+
# split by { open, closed }
24+
# split by { bug, feature, neither }
25+
# each split by { p1, p2, p3, p4, p5, unprioritised } <- priority
26+
# each split by { minor, major, critical, cosmetic, network, no-severity } <- severity
27+
# then split (with overlap between the groups) as { total, tag1, tag2, ... }?
28+
29+
# ...and then all over again split by milestone.
30+
31+
my $days = {};
32+
my $schema = {};
33+
my $now = DateTime->now();
34+
35+
foreach my $issue (@issues) {
36+
next if ($issue->{pull_request});
37+
38+
use Data::Dumper;
39+
print STDERR Dumper($issue);
40+
41+
my @label_list = map { $_->{name} } @{$issue->{labels}};
42+
my $labels = {};
43+
$labels->{$_} = 1 foreach (@label_list);
44+
$labels->{bug}++ if ($labels->{cosmetic} && !$labels->{bug} && !$labels->{feature});
45+
46+
my $extract_labels = sub {
47+
my $label = undef;
48+
foreach (@_) {
49+
$label ||= $_ if (delete $labels->{$_});
50+
}
51+
return $label;
52+
};
53+
54+
my $type = &$extract_labels(qw(bug feature)) || "neither";
55+
my $priority = &$extract_labels(qw(p1 p2 p3 p4 p5)) || "unprioritised";
56+
my $severity = &$extract_labels(qw(minor major critical cosmetic network)) || "no-severity";
57+
58+
my $start = DateTime::Format::ISO8601->parse_datetime($issue->{created_at});
59+
my $end = $issue->{closed_at} ? DateTime::Format::ISO8601->parse_datetime($issue->{closed_at}) : $now;
60+
61+
do {
62+
my $ymd = $start->ymd();
63+
64+
$days->{ $ymd }->{ $type }->{ $priority }->{ $severity }->{ total }++;
65+
$schema->{ $type }->{ $priority }->{ $severity }->{ total }++;
66+
foreach (keys %$labels) {
67+
$days->{ $ymd }->{ $type }->{ $priority }->{ $severity }->{ $_ }++;
68+
$schema->{ $type }->{ $priority }->{ $severity }->{ $_ }++;
69+
}
70+
71+
$start = $start->add(days => 1);
72+
} while (DateTime->compare($start, $end) < 0);
73+
}
74+
75+
print "day,";
76+
foreach my $type (sort keys %{$schema}) {
77+
foreach my $priority (sort keys %{$schema->{$type}}) {
78+
foreach my $severity (sort keys %{$schema->{$type}->{$priority}}) {
79+
# foreach my $tag (sort keys %{$schema->{$type}->{$priority}->{$severity}}) {
80+
# print "\"$type\n$priority\n$severity\n$tag\",";
81+
# }
82+
print "\"$type\n$priority\n$severity\",";
83+
}
84+
}
85+
}
86+
print "\n";
87+
88+
foreach my $day (sort keys %$days) {
89+
print "$day,";
90+
foreach my $type (sort keys %{$schema}) {
91+
foreach my $priority (sort keys %{$schema->{$type}}) {
92+
foreach my $severity (sort keys %{$schema->{$type}->{$priority}}) {
93+
# foreach my $tag (sort keys %{$schema->{$type}->{$priority}->{$severity}}) {
94+
# print $days->{$day}->{$type}->{$priority}->{$severity}->{$tag} || 0;
95+
# print ",";
96+
# }
97+
print $days->{$day}->{$type}->{$priority}->{$severity}->{total} || 0;
98+
print ",";
99+
}
100+
}
101+
}
102+
print "\n";
103+
}
104+

0 commit comments

Comments
 (0)