use POSIX qw(strftime tzset nice);
#require '/usr/lib/debbugs/errorlib';
-#require '/usr/lib/debbugs/common.pl';
-require '/debian/home/ajt/newajbug/common.pl';
+require './common.pl';
require '/etc/debbugs/config';
require '/etc/debbugs/text';
my %param = readparse();
my $indexon = $param{'indexon'} || 'pkg';
-if ($indexon !~ m/^(pkg|maint|submitter)/) {
+if ($indexon !~ m/^(pkg|maint|submitter)$/) {
quit("You have to choose something to index on");
}
my $repeatmerged = ($param{'repeatmerged'} || "yes") eq "yes";
my $archive = ($param{'archive'} || "no") eq "yes";
+my $sortby = $param{'sortby'} || 'alpha';
+if ($sortby !~ m/^(alpha|count)$/) {
+ quit("Don't know how to sort like that");
+}
+
#my $include = $param{'include'} || "";
#my $exclude = $param{'exclude'} || "";
my %count;
my $tag;
my $note;
-my $linksub;
+my %htmldescrip = ();
+my %sortkey = ();
if ($indexon eq "pkg") {
$tag = "package";
%count = countbugs(sub {my %d=@_; return $d{"pkg"}});
$note = "<p>Note that with multi-binary packages there may be other\n";
$note .= "reports filed under the different binary package names.</p>\n";
- $linksub = sub {
- my $pkg = shift;
- sprintf('<a href="%s">%s</a> '
- . '(maintained by <a href="%s">%s</a>',
+ foreach my $pkg (keys %count) {
+ $sortkey{$pkg} = lc $pkg;
+ $htmldescrip{$pkg} = sprintf('<a href="%s">%s</a> '
+ . '(maintainer: <a href="%s">%s</a>)',
pkgurl($pkg),
htmlsanit($pkg),
mainturl($maintainers{$pkg}),
- htmlsanit($maintainers{$pkg}));
- };
+ htmlsanit($maintainers{$pkg} || "(unknown)"));
+ }
} elsif ($indexon eq "maint") {
$tag = "maintainer";
%count = countbugs(sub {my %d=@_;
$note = "<p>Note that maintainers may use different Maintainer fields for\n";
$note .= "different packages, so there may be other reports filed under\n";
$note .= "different addresses.</p>\n";
- $linksub = sub {
- my $maint = shift; my $maintfull = $maint;
- foreach my $x (values %maintainers) {
- if (emailfromrfc822($x) eq $maint) {
- $maintfull = $x; last;
- }
- }
- sprintf('<a href="%s">%s</a>',
+ my %email2maint = ();
+ for my $x (values %maintainers) {
+ my $y = emailfromrfc822($x);
+ $email2maint{$y} = $x unless (defined $email2maint{$y});
+ }
+ foreach my $maint (keys %count) {
+ $sortkey{$maint} = lc $email2maint{$maint} || "(unknown)";
+ $htmldescrip{$maint} = sprintf('<a href="%s">%s</a>',
mainturl($maint),
- htmlsanit($maintfull));
- };
+ htmlsanit($email2maint{$maint}) || "(unknown)")
+ }
} elsif ($indexon eq "submitter") {
$tag = "submitter";
my %fullname = ();
$fullname{$em} = $f if (!defined $fullname{$em});
return $em;
});
- $linksub = sub {
- my $sub = shift;
- sprintf('<a href="%s">%s</a>',
+ foreach my $sub (keys %count) {
+ $sortkey{$sub} = lc $fullname{$sub};
+ $htmldescrip{$sub} = sprintf('<a href="%s">%s</a>',
submitterurl($sub),
htmlsanit($fullname{$sub}));
- };
+ }
$note = "<p>Note that people may use different email accounts for\n";
$note .= "different bugs, so there may be other reports filed under\n";
$note .= "different addresses.</p>\n";
}
my $result = "<ul>\n";
-foreach my $x (sort keys %count) {
- $result .= "<li>" . $linksub->($x) . " has $count{$x} bugs</li>\n";
+my @orderedentries;
+if ($sortby eq "count") {
+ @orderedentries = sort { $count{$a} <=> $count{$b} } keys %count;
+} else { # sortby alpha
+ @orderedentries = sort { $sortkey{$a} cmp $sortkey{$b} } keys %count;
+}
+foreach my $x (@orderedentries) {
+ $result .= "<li>" . $htmldescrip{$x} . " has $count{$x} " .
+ ($count{$x} == 1 ? "bug" : "bugs") . "</li>\n";
}
$result .= "</ul>\n";
print "Content-Type: text/html\n\n";
+print "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">\n";
print "<HTML><HEAD><TITLE>\n" .
"$debbugs::gProject $Archived $debbugs::gBug reports by $tag\n" .
"</TITLE></HEAD>\n" .
'<BODY TEXT="#000000" BGCOLOR="#FFFFFF" LINK="#0000FF" VLINK="#800080">' .
"\n";
-print "<H1>" . "$debbugs::gProject $Archived $debbugs::gBug report logs: $tag" .
+print "<H1>" . "$debbugs::gProject $Archived $debbugs::gBug report logs by $tag" .
"</H1>\n";
print $note;