[rt-viewer commit] r5 - trunk/bin

0 views
Skip to first unread message

codesite...@google.com

unread,
Jan 8, 2008, 9:09:28 AM1/8/08
to rt-viewe...@googlegroups.com
Author: wcoleda
Date: Tue Jan 8 06:08:42 2008
New Revision: 5

Modified:
trunk/bin/get_tickets.pl

Log:
bundle the network traffic a bit, avoid invoking the RT command line
multiple times.


Modified: trunk/bin/get_tickets.pl
==============================================================================
--- trunk/bin/get_tickets.pl (original)
+++ trunk/bin/get_tickets.pl Tue Jan 8 06:08:42 2008
@@ -13,6 +13,18 @@
my %headers = map {$_, 1} qw/ subject priority id owner requestor
lastupdated queue status/;

my $base_query = q{Queue="parrot" and Status != "resolved" and Status != "rejected"};
+
+# Get all the parrot tickets and subjects.
+my %cache;
+for my $output (`rt ls '$base_query'`) {
+ if ($output =~ m/^(\d+)+:\s+(.*)/) {
+ $cache{$1} = $2;
+ }
+}
+
+# Hash of query names to arrayrefs of ticketnumbers, or a promise
+# to return an array ref of ticket numbers.
+
my $queries = {
'perl6' => sub {
my @out = `rt show -f DependsOn ticket/49171/links`;
@@ -22,21 +34,20 @@
}
};

-my @tag_style = qw/CAGE TODO DEPRECATED BUG PATCH RFC RFE PROPOSAL
Perl C PIR/;
-foreach my $tag (@tag_style) {
- $queries->{$tag} = sub {
- my $cmd = sprintf "rt ls '$base_query %s'", like($tag);
- my @out = `$cmd`;
- return grep {$_ ne ""} map {
- s{^(\d+)}{$1} && $1;
- } @out;
+# Get ticket numbers from all the [TAGS] we care about.
+my @tags = qw/CAGE TODO DEPRECATED BUG PATCH RFC RFE PROPOSAL Perl C PIR/;
+foreach my $tag (@tags) {
+ foreach my $ticket (keys %cache) {
+ if ($cache{$ticket} =~ /\[$tag\]/) {
+ push @{$queries->{$tag}}, $ticket;
+ }
}
}

my @lang_style = qw/tcl/;
foreach my $lang (@lang_style) {
$queries->{$lang} = sub {
- my $cmd = sprintf "rt ls '$base_query %s'", lang($lang);
+ my $cmd = qq{rt ls '$base_query and "CF.parrot.{LANG}"="$lang"'};
my @out = `$cmd`;
return grep {$_ ne ""} map {
s{^(\d+)}{$1} && $1;
@@ -44,6 +55,7 @@
}
}

+# Default to generating everything, but allow user to generate a subset
my @query_list = keys %$queries;
if (@ARGV) { @query_list = @ARGV; }

@@ -52,8 +64,15 @@
my $filename = $output_dir . '/' . $query . '.json';
warn "\nGenerating $filename\n";

- my @tickets = $queries->{$query}->();
- my $json = { 'tickets' => [ map {get_ticket($_)} @tickets ] };
+ my $tickets = $queries->{$query};
+
+ # If this is a promise, collect on it.
+ if (ref $tickets eq 'CODE') {
+ $tickets = [ &$tickets() ];
+ }
+
+ # Get all the ticket information for these tickets.
+ my $json = { 'tickets' => [ map {get_ticket($_)} @$tickets ] };

open my $fh, '>', $filename;
print {$fh} to_json( $json );
@@ -105,13 +124,3 @@
}
}

-
-sub like {
- my $tag = shift;
- return 'and Subject like "%['. $tag . ']%"';
-}
-
-sub lang {
- my $lang = shift;
- return 'and "CF.parrot.{LANG}" = "' . $lang . '"';
-}

Reply all
Reply to author
Forward
0 new messages