rt.cpan.org, sort by severity

brian_d_foy on 2007-11-25T15:12:00

It's always annoyed me that rt.cpan.org can no longer sort tickets by severity. This isn't such a big deal unless you have a lot of tickets, as I do. MakeMaker alone has over 90.

I found RT::Client::REST and hacked up their example to produce for me a list by severity. Yay! If one cared, you could encode the search results as JSON and make some sort of clever web interface with resortable columns.

#!/usr/bin/perl -w
 
use strict;
 
use Error qw(:try);
 
use RT::Client::REST;
 
my %Config = (
    server      => 'http://rt.cpan.org',
    username    => 'YOU',
    password    => 'wouldn't you like to know',
    queue       => 'Your-Module'
);
 
my $rt = RT::Client::REST->new(
    server  => $Config{server},
    timeout => 30
);
 
try {
    $rt->login( username => $Config{username}, password => $Config{password} );
}
catch Exception::Class::Base with {
    die "problem logging in: ", shift->message;
};
 
my @ids;
try {
    @ids = $rt->search(
        type    => 'ticket',
        query   => qq[
            (Status = 'new' or Status = 'open')
            and
            Queue = '$Config{queue}'
        ],
        orderby => 'CustomField.{Severity}'
    );
}
catch Exception::Class::Base with {
    die "search failed", shift->message;
};
 
for my $id (@ids) {
    my $ticket = $rt->show(type => 'ticket', id => $id);
    print "ID: $id\n";
    print "\tSubject: ", $ticket->{Subject}, "\n";
    print "\tSeverity: ", $ticket->{"CF-Severity"}, "\n";
}