Skip to content

Commit 28b9892

Browse files
committed
burndown generator
1 parent 512a912 commit 28b9892

File tree

1 file changed

+124
-0
lines changed

1 file changed

+124
-0
lines changed

scripts/issues-burndown.pl

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
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 $state = $issue->{state};
55+
my $type = &$extract_labels(qw(bug feature)) || "neither";
56+
my $priority = &$extract_labels(qw(p1 p2 p3 p4 p5)) || "unprioritised";
57+
my $severity = &$extract_labels(qw(minor major critical cosmetic network)) || "no-severity";
58+
59+
my $start = DateTime::Format::ISO8601->parse_datetime($issue->{created_at});
60+
61+
do {
62+
my $ymd = $start->ymd();
63+
64+
$days->{ $ymd }->{ 'created' }->{ $type }->{ $priority }->{ $severity }->{ total }++;
65+
$schema->{ 'created' }->{ $type }->{ $priority }->{ $severity }->{ total }++;
66+
foreach (keys %$labels) {
67+
$days->{ $ymd }->{ 'created' }->{ $type }->{ $priority }->{ $severity }->{ $_ }++;
68+
$schema->{ 'created' }->{ $type }->{ $priority }->{ $severity }->{ $_ }++;
69+
}
70+
71+
$start = $start->add(days => 1);
72+
} while (DateTime->compare($start, $now) < 0);
73+
74+
if ($state eq 'closed') {
75+
my $end = DateTime::Format::ISO8601->parse_datetime($issue->{closed_at});
76+
do {
77+
my $ymd = $end->ymd();
78+
79+
$days->{ $ymd }->{ 'resolved' }->{ $type }->{ $priority }->{ $severity }->{ total }++;
80+
$schema->{ 'resolved' }->{ $type }->{ $priority }->{ $severity }->{ total }++;
81+
foreach (keys %$labels) {
82+
$days->{ $ymd }->{ 'resolved' }->{ $type }->{ $priority }->{ $severity }->{ $_ }++;
83+
$schema->{ 'resolved' }->{ $type }->{ $priority }->{ $severity }->{ $_ }++;
84+
}
85+
86+
$end = $end->add(days => 1);
87+
} while (DateTime->compare($end, $now) < 0);
88+
}
89+
}
90+
91+
print "day,";
92+
foreach my $state (sort keys %{$schema}) {
93+
foreach my $type (grep { /^(bug|feature)$/ } sort keys %{$schema->{$state}}) {
94+
foreach my $priority (grep { /^(p1|p2)$/ } sort keys %{$schema->{$state}->{$type}}) {
95+
foreach my $severity (sort keys %{$schema->{$state}->{$type}->{$priority}}) {
96+
# foreach my $tag (sort keys %{$schema->{$state}->{$type}->{$priority}->{$severity}}) {
97+
# print "\"$type\n$priority\n$severity\n$tag\",";
98+
# }
99+
print "\"$state\n$type\n$priority\n$severity\",";
100+
}
101+
}
102+
}
103+
}
104+
print "\n";
105+
106+
foreach my $day (sort keys %$days) {
107+
print "$day,";
108+
foreach my $state (sort keys %{$schema}) {
109+
foreach my $type (grep { /^(bug|feature)$/ } sort keys %{$schema->{$state}}) {
110+
foreach my $priority (grep { /^(p1|p2)$/ } sort keys %{$schema->{$state}->{$type}}) {
111+
foreach my $severity (sort keys %{$schema->{$state}->{$type}->{$priority}}) {
112+
# foreach my $tag (sort keys %{$schema->{$state}->{$type}->{$priority}->{$severity}}) {
113+
# print $days->{$day}->{$state}->{$type}->{$priority}->{$severity}->{$tag} || 0;
114+
# print ",";
115+
# }
116+
print $days->{$day}->{$state}->{$type}->{$priority}->{$severity}->{total} || 0;
117+
print ",";
118+
}
119+
}
120+
}
121+
}
122+
print "\n";
123+
}
124+

0 commit comments

Comments
 (0)