]> git.donarmstrong.com Git - debbugs.git/commitdiff
* Add support for the correspondent index
authorDon Armstrong <don@donarmstrong.com>
Thu, 19 Jun 2008 00:10:35 +0000 (17:10 -0700)
committerDon Armstrong <don@donarmstrong.com>
Thu, 19 Jun 2008 00:10:35 +0000 (17:10 -0700)
scripts/gen-indices

index 11775e479edc1f87feb73839a73d7f07b06f628d..ca115465afc9eaa4ae768a1cdd9cb655cb82e739 100755 (executable)
@@ -1,8 +1,13 @@
 #!/usr/bin/perl
+# gen-indices generates bug index files, and is released
+# under the terms of the GPL version 2, or any later version, at your
+# option. See the file README and COPYING for more information.
 
-# Generates by-*.idx files for the CGI scripts
 # Copyright (c) 2005/08/03 Anthony Towns
-# GPL v2
+# Copyright 2007, 2008 by Don Armstrong <don@donarmstrong.com>.
+
+use warnings;
+use strict;
 
 use DB_File;
 use MLDBM qw(DB_FILE Storable);
@@ -12,9 +17,6 @@ use File::Copy;
 use Getopt::Long;
 use Pod::Usage;
 
-use warnings;
-use strict;
-
 use File::stat;
 use List::Util qw(min);
 
@@ -78,6 +80,7 @@ pod2usage(-verbose=>2) if $options{man};
 use Debbugs::Config qw(:config);
 use Debbugs::Common qw(getparsedaddrs getbugcomponent lockpid);
 use Debbugs::Status qw(readbug);
+use Debbugs::Log;
 
 chdir($config{spool_dir}) or die "chdir $config{spool_dir} failed: $!";
 
@@ -103,7 +106,7 @@ if (not lockpid($config{spool_dir}.'/lock/gen-indices')) {
 }
 
 # NB: The reverse index is special; it's used to clean up during updates to bugs
-my @indexes = ('package', 'tag', 'severity','owner','submitter-email','status','reverse');
+my @indexes = ('package', 'tag', 'severity','owner','submitter-email','status','correspondent','reverse');
 my $indexes;
 my %slow_index = ();
 my %fast_index = ();
@@ -200,7 +203,23 @@ while (my $dir = shift @dirs) {
                addbugtoindex("severity", $bug, $fdata->{"severity"});
                addbugtoindex("owner", $bug,
                              map {lc($_->address)} getparsedaddrs($fdata->{"owner"}));
-       }
+               # handle log entries
+               # do this in eval to avoid exploding on jacked logs
+               eval {
+                    my $log = Debbugs::Log->new(bug_num => $bug);
+                    while (my $record = $log->read_record()) {
+                         next unless $record->{type} eq 'incoming-recv';
+                         # we use a regex here, because a full mime parse will be slow.
+                         my ($from) = $record->{text} =~ /^From:\s+(.+?)^\S/ism;
+                         addbugtoindex('correspondent',$bug,
+                                       map {lc($_->address)} getparsedaddrs($from)
+                                      );
+                    }
+               };
+               if ($@) {
+                    print STDERR "Problem dealing with log of $bug: $@";
+               }
+          }
 }
 
 if (not $options{quick}) {