|
4 | 4 | use strict; |
5 | 5 |
|
6 | 6 | use Net::GitHub; |
7 | | -use DateTime; |
8 | | -use DateTime::Format::ISO8601; |
| 7 | +use Time::Moment; |
| 8 | +use Term::ReadPassword; |
| 9 | + |
| 10 | +# This version of the script emits the cumulative number of bugs, split into open & closed |
| 11 | +# suitable for drawing the 'top' and 'bottom' of a burndown graph. |
| 12 | +# |
| 13 | +# N.B. this doesn't take into account issues changing priority over time, but only their most recent priority. |
| 14 | +# |
| 15 | +# If you want instead the number of open issues on a given day, then look at issues-no-state.pl |
9 | 16 |
|
10 | 17 | my $gh = Net::GitHub->new( |
11 | | - login => 'ara4n', pass => 'secret' |
| 18 | + login => 'ara4n', pass => read_password("github password: "), |
12 | 19 | ); |
13 | 20 |
|
14 | 21 | $gh->set_default_user_repo('vector-im', 'vector-web'); |
15 | 22 |
|
16 | | -my @issues = $gh->issue->repos_issues({ state => 'all', milestone => 3 }); |
| 23 | +#my @issues = $gh->issue->repos_issues({ state => 'all', milestone => 3 }); |
| 24 | +my @issues = $gh->issue->repos_issues({ state => 'all' }); |
17 | 25 | while ($gh->issue->has_next_page) { |
18 | 26 | push @issues, $gh->issue->next_page; |
19 | 27 | } |
|
30 | 38 |
|
31 | 39 | my $days = {}; |
32 | 40 | my $schema = {}; |
33 | | -my $now = DateTime->now(); |
| 41 | +my $now = Time::Moment->now; |
34 | 42 |
|
35 | 43 | foreach my $issue (@issues) { |
36 | 44 | next if ($issue->{pull_request}); |
37 | | - |
| 45 | + |
38 | 46 | # use Data::Dumper; |
39 | 47 | # print STDERR Dumper($issue); |
40 | 48 |
|
|
56 | 64 | my $priority = &$extract_labels(qw(p1 p2 p3 p4 p5)) || "unprioritised"; |
57 | 65 | my $severity = &$extract_labels(qw(minor major critical cosmetic network)) || "no-severity"; |
58 | 66 |
|
59 | | - my $start = DateTime::Format::ISO8601->parse_datetime($issue->{created_at}); |
| 67 | + my $start = Time::Moment->from_string($issue->{created_at}); |
60 | 68 |
|
61 | 69 | do { |
62 | | - my $ymd = $start->ymd(); |
| 70 | + my $ymd = $start->strftime('%F'); |
63 | 71 |
|
64 | 72 | $days->{ $ymd }->{ 'created' }->{ $type }->{ $priority }->{ $severity }->{ total }++; |
65 | 73 | $schema->{ 'created' }->{ $type }->{ $priority }->{ $severity }->{ total }++; |
|
68 | 76 | $schema->{ 'created' }->{ $type }->{ $priority }->{ $severity }->{ $_ }++; |
69 | 77 | } |
70 | 78 |
|
71 | | - $start = $start->add(days => 1); |
72 | | - } while (DateTime->compare($start, $now) < 0); |
| 79 | + $start = $start->plus_days(1); |
| 80 | + # print STDERR "^"; |
| 81 | + } while ($start->compare($now) < 0); |
73 | 82 |
|
74 | 83 | if ($state eq 'closed') { |
75 | | - my $end = DateTime::Format::ISO8601->parse_datetime($issue->{closed_at}); |
| 84 | + my $end = Time::Moment->from_string($issue->{closed_at}); |
76 | 85 | do { |
77 | | - my $ymd = $end->ymd(); |
| 86 | + my $ymd = $end->strftime('%F'); |
78 | 87 |
|
79 | 88 | $days->{ $ymd }->{ 'resolved' }->{ $type }->{ $priority }->{ $severity }->{ total }++; |
80 | 89 | $schema->{ 'resolved' }->{ $type }->{ $priority }->{ $severity }->{ total }++; |
|
83 | 92 | $schema->{ 'resolved' }->{ $type }->{ $priority }->{ $severity }->{ $_ }++; |
84 | 93 | } |
85 | 94 |
|
86 | | - $end = $end->add(days => 1); |
87 | | - } while (DateTime->compare($end, $now) < 0); |
| 95 | + $end = $end->plus_days(1); |
| 96 | + } while ($end->compare($now) < 0); |
| 97 | + # print STDERR "v"; |
88 | 98 | } |
| 99 | + |
| 100 | + # print STDERR "\n"; |
89 | 101 | } |
90 | 102 |
|
91 | 103 | print "day,"; |
|
0 commit comments