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