]> git.donarmstrong.com Git - debbugs.git/blob - scripts/summary.in
[project @ 1999-09-02 22:27:29 by gecko]
[debbugs.git] / scripts / summary.in
1 #!/usr/bin/perl
2 # $Id: summary.in,v 1.2 1999/09/02 22:27:29 gecko Exp $
3
4 require('/etc/debbugs/config');
5 require('/usr/lib/debbugs/errorlib');
6 chdir("$gSpoolDir") || die "chdir spool: $!\n";
7
8 #open(DEBUG,">&4");
9
10 $mode= shift(@ARGV);
11
12 open(M,"$gMaintainerFile") || &quit("open $gMaintainerFile: $!");
13 while (<M>) {
14     m/^(\S+)\s+(\S.*\S)\s*$/ || warn "$_ ?";
15     ($a,$b)=($1,$2);
16     $a =~ y/A-Z/a-z/;
17     $maintainer{$a}= $b;
18 }
19 close(M);
20
21 defined($startdate= time) || &quit("failed to get time: $!");
22
23 opendir(DIR,"db") || &quit("opendir db: $!\n");
24 @list= grep(m/^\d+\.status$/,readdir(DIR));
25 grep(s/\.status$//,@list);
26 @list= sort { $a <=> $b } @list;
27
28 $head= $mode eq 'bymaint'
29     ? ' Package     Ref    Subject'
30     : ' Ref   Package    Keywords/Subject               Package maintainer';
31 $amonths=-1;
32
33 while (length($f=shift(@list))) {
34     &filelock("lock/$f");
35     if (!open(S,"db/$f.status")) { &unlinklock; next; }
36     chop($s_originator= <S>);
37     chop($s_date= <S>);
38     chop($s_subject= <S>);
39     chop($s_msgid= <S>);
40     chop($s_package= <S>);
41     chop($s_keywords= <S>);
42     chop($s_done= <S>);
43     chop($s_forwarded= <S>);
44     $_= $s_package; y/A-Z/a-z/; $_= $` if m/[^-+._a-z0-9]/;
45     $s_maintainer=
46         defined($maintainer{$_}) ? $maintainer{$_} :
47         length($_) ? "(unknown -- \`$_')" :
48         "(unknown)";
49     if ($mode eq 'undone' || $mode eq 'veryold') {
50         &unfilelock;
51         next if length($s_done) || length($s_forwarded);
52         $cmonths= int(($startdate - $s_date)/2592000); # 3600*24*30 (30 days)
53         next if $mode eq 'veryold' && $cmonths < 2;
54         if ($cmonths != $amonths) {
55             $msg= $cmonths == 0 ? "Submitted in the last month" :
56                   $cmonths == 1 ? "Over one month old" :
57                   $cmonths == 2 ? "Over two months old - attention is required" :
58                                   "OVER $cmonths MONTHS OLD - ATTENTION IS REQUIRED";
59             print "\n$msg:\n$head\n";
60             $amonths= $cmonths;
61         }
62         printf("%6d %-10.10s %-30.30s %-.31s\n", $f, $s_package,
63                (length($s_keywords) ? $s_keywords.'/' : '').$s_subject,
64                $s_maintainer) || &quit("output undone: $!");
65     } elsif ($mode eq 'bymaint') {
66         &unfilelock;
67         next if length($s_done) || length($s_forwarded);
68         $string{$f}=
69             sprintf(" %-10.10s %6d  %-.59s\n", $s_package, $f, $s_subject);
70         $s_maintainer= "(unknown)" if $s_maintainer =~ m/^\(unknown \-\-/;
71         $maintainercnt{$s_maintainer}++;
72         $maintainerlist{$s_maintainer}.= " $f";
73     } else {
74         &quit("badmode $mode");
75     }
76 }
77
78 if ($mode eq 'bymaint') {
79     print("$head\n") || &quit("output head: $!");
80     for $m (sort { $maintainercnt{$a} <=> $maintainercnt{$b} } keys %maintainercnt) {
81         printf("\n%s (%d $gBugs):\n",$m,$maintainercnt{$m})
82             || &quit("output mainthead: $!");
83         for $i (sort { $string{$a} cmp $string{$b} } split(/ /,$maintainerlist{$m})) {
84             printf($string{$i}) || &quit("output 1bymaint: $!");
85         }
86     }
87 }
88
89 close(STDOUT) || &quit("close stdout: $!");