[Bps-public-commit] RT-Extension-rt_cpan_org branch, master, updated. c86868e76d3f13db90c0aea5e5b681669514380f
Thomas Sibley
trs at bestpractical.com
Mon Apr 29 16:51:36 EDT 2013
The branch, master has been updated
via c86868e76d3f13db90c0aea5e5b681669514380f (commit)
from 992c1befb9d1492fc69fe08232d4a61075ccc8e3 (commit)
Summary of changes:
bin/rt-cpan-bugs-per-dists | 18 ++++++++++++++----
1 file changed, 14 insertions(+), 4 deletions(-)
- Log -----------------------------------------------------------------
commit c86868e76d3f13db90c0aea5e5b681669514380f
Author: Thomas Sibley <trs at bestpractical.com>
Date: Mon Apr 29 13:48:34 2013 -0700
Sum active/inactive bug counts and use lifecycles to get statuses
The hardcoded statuses missed the "patched" status; using lifecycles
fixes it.
diff --git a/bin/rt-cpan-bugs-per-dists b/bin/rt-cpan-bugs-per-dists
index 055bf11..9d6e429 100755
--- a/bin/rt-cpan-bugs-per-dists
+++ b/bin/rt-cpan-bugs-per-dists
@@ -2,6 +2,8 @@
use strict;
use warnings;
+use List::Util "sum";
+
eval { require RT; 1 } or do {
print STDERR "$@\n\nusage: perl -I /opt/rt4/local/lib -I/opt/rt4/lib $0 > results.tsv\n";
exit 1;
@@ -30,17 +32,20 @@ my $query = q{
my $sth = $dbh->prepare($query);
$sth->execute('ticket');
-my @statuses = qw(new open stalled resolved rejected);
+my $lifecycle = RT::Lifecycle->Load("default");
+my @active = $lifecycle->Valid("initial", "active");
+my @inactive = grep { $_ ne "deleted" } $lifecycle->Valid("inactive");
+my @statuses = (@active, @inactive);
my $date = `date`;
chomp $date;
print "# Generated on $date\n";
-print "# ", join("\t", "dist", @statuses), "\n";
+print "# ", join("\t", "dist", @statuses, "active", "inactive"), "\n";
my %buffer = ('dist' => '');
while (my ($dist, $status, $count) = $sth->fetchrow_array) {
if ( $buffer{dist} && $buffer{dist} ne $dist ) {
- print join("\t", $buffer{dist}, map $_ || 0, @{ $buffer{counts} }{ @statuses } ), "\n";
+ print_line();
%buffer = ( dist => $dist, counts => { $status => $count } );
} else {
@@ -48,5 +53,10 @@ while (my ($dist, $status, $count) = $sth->fetchrow_array) {
$buffer{counts}{ $status } = $count;
}
}
-print join("\t", $buffer{dist}, map $_ || 0, @{ $buffer{counts} }{ @statuses } ), "\n";
+print_line();
+sub print_line {
+ $buffer{counts}{"active"} = sum map $_ || 0, @{ $buffer{counts} }{ @active };
+ $buffer{counts}{"inactive"} = sum map $_ || 0, @{ $buffer{counts} }{ @inactive };
+ print join("\t", $buffer{dist}, map $_ || 0, @{ $buffer{counts} }{ @statuses, "active", "inactive" } ), "\n";
+}
-----------------------------------------------------------------------
More information about the Bps-public-commit
mailing list