Skip to content

Commit 1e5908a

Browse files
committed
speed up burndown generation by ~250x
1 parent 40c98fc commit 1e5908a

2 files changed

Lines changed: 36 additions & 16 deletions

File tree

‎scripts/issues-burndown.pl‎

100644100755
Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,24 @@
44
use strict;
55

66
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
916

1017
my $gh = Net::GitHub->new(
11-
login => 'ara4n', pass => 'secret'
18+
login => 'ara4n', pass => read_password("github password: "),
1219
);
1320

1421
$gh->set_default_user_repo('vector-im', 'vector-web');
1522

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' });
1725
while ($gh->issue->has_next_page) {
1826
push @issues, $gh->issue->next_page;
1927
}
@@ -30,11 +38,11 @@
3038

3139
my $days = {};
3240
my $schema = {};
33-
my $now = DateTime->now();
41+
my $now = Time::Moment->now;
3442

3543
foreach my $issue (@issues) {
3644
next if ($issue->{pull_request});
37-
45+
3846
# use Data::Dumper;
3947
# print STDERR Dumper($issue);
4048

@@ -56,10 +64,10 @@
5664
my $priority = &$extract_labels(qw(p1 p2 p3 p4 p5)) || "unprioritised";
5765
my $severity = &$extract_labels(qw(minor major critical cosmetic network)) || "no-severity";
5866

59-
my $start = DateTime::Format::ISO8601->parse_datetime($issue->{created_at});
67+
my $start = Time::Moment->from_string($issue->{created_at});
6068

6169
do {
62-
my $ymd = $start->ymd();
70+
my $ymd = $start->strftime('%F');
6371

6472
$days->{ $ymd }->{ 'created' }->{ $type }->{ $priority }->{ $severity }->{ total }++;
6573
$schema->{ 'created' }->{ $type }->{ $priority }->{ $severity }->{ total }++;
@@ -68,13 +76,14 @@
6876
$schema->{ 'created' }->{ $type }->{ $priority }->{ $severity }->{ $_ }++;
6977
}
7078

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);
7382

7483
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});
7685
do {
77-
my $ymd = $end->ymd();
86+
my $ymd = $end->strftime('%F');
7887

7988
$days->{ $ymd }->{ 'resolved' }->{ $type }->{ $priority }->{ $severity }->{ total }++;
8089
$schema->{ 'resolved' }->{ $type }->{ $priority }->{ $severity }->{ total }++;
@@ -83,9 +92,12 @@
8392
$schema->{ 'resolved' }->{ $type }->{ $priority }->{ $severity }->{ $_ }++;
8493
}
8594

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";
8898
}
99+
100+
# print STDERR "\n";
89101
}
90102

91103
print "day,";

‎scripts/issues-no-state.pl‎

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,22 @@
66
use Net::GitHub;
77
use DateTime;
88
use DateTime::Format::ISO8601;
9+
use Term::ReadPassword;
10+
11+
# This version of the script emits the total number of bugs open on a given day,
12+
# split by various tags.
13+
#
14+
# If you want instead the cumulative number of open & closed issues on a given day,
15+
# then look at issues-burndown.pl
916

1017
my $gh = Net::GitHub->new(
11-
login => 'ara4n', pass => 'secret'
18+
login => 'ara4n', pass => read_password("github password: "),
1219
);
1320

1421
$gh->set_default_user_repo('vector-im', 'vector-web');
1522

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' });
1725
while ($gh->issue->has_next_page) {
1826
push @issues, $gh->issue->next_page;
1927
}

0 commit comments

Comments
 (0)