about summary refs log tree commit homepage
path: root/lib/PublicInbox/SearchIdx.pm
diff options
context:
space:
mode:
authorEric Wong <e@yhbt.net>2020-03-20 08:18:20 +0000
committerEric Wong <e@yhbt.net>2020-03-22 09:00:23 +0000
commitb5bc3576af3d0ef0fa884ed32a674c7a703a19b2 (patch)
tree990be6a2a7f0440154e7aa903cd430a2735eb975 /lib/PublicInbox/SearchIdx.pm
parent99d6d24847c499387ce65b09305deebfd51f8930 (diff)
downloadpublic-inbox-b5bc3576af3d0ef0fa884ed32a674c7a703a19b2.tar.gz
We can finally get rid of the awkward, ad-hoc use of V2Writable,
SearchIdx, and OverIdx args for passing {cotime} and {autime}
between classes.

We'll still use those git time fields internally within
V2Writable and SearchIdx for (re)indexing, but that's not
worth avoiding as a fallback.
Diffstat (limited to 'lib/PublicInbox/SearchIdx.pm')
-rw-r--r--lib/PublicInbox/SearchIdx.pm16
1 files changed, 10 insertions, 6 deletions
diff --git a/lib/PublicInbox/SearchIdx.pm b/lib/PublicInbox/SearchIdx.pm
index 5ca819c3..44b05813 100644
--- a/lib/PublicInbox/SearchIdx.pm
+++ b/lib/PublicInbox/SearchIdx.pm
@@ -310,8 +310,6 @@ sub add_xapian ($$$$) {
         my ($self, $mime, $smsg, $mids) = @_;
         $smsg->{mime} = $mime; # XXX dangerous
         my $hdr = $mime->header_obj;
-        $smsg->{ds} = msg_datestamp($hdr, $self->{autime});
-        $smsg->{ts} = msg_timestamp($hdr, $self->{cotime});
         my $doc = $X->{Document}->new;
         my $subj = $smsg->subject;
         add_val($doc, PublicInbox::Search::TS(), $smsg->{ts});
@@ -368,13 +366,19 @@ sub _msgmap_init ($) {
 sub add_message {
         # mime = Email::MIME object
         my ($self, $mime, $smsg) = @_;
-        my $mids = mids_for_index($mime->header_obj);
+        my $hdr = $mime->header_obj;
+        my $mids = mids_for_index($hdr);
         $smsg //= bless { blob => '' }, 'PublicInbox::Smsg'; # test-only compat
         $smsg->{mid} //= $mids->[0]; # v1 compatibility
         $smsg->{num} //= do { # v1
                 _msgmap_init($self);
                 index_mm($self, $mime);
         };
+
+        # v1 and tests only:
+        $smsg->{ds} //= msg_datestamp($hdr, $self->{autime});
+        $smsg->{ts} //= msg_timestamp($hdr, $self->{cotime});
+
         eval {
                 # order matters, overview stores every possible piece of
                 # data in doc_data (deflated).  Xapian only stores a subset
@@ -382,7 +386,7 @@ sub add_message {
                 # storing doc_data in Xapian sometime after we get multi-inbox
                 # search working.
                 if (my $over = $self->{over}) { # v1 only
-                        $over->add_overview($mime, $smsg, $self);
+                        $over->add_overview($mime, $smsg);
                 }
                 if (need_xapian($self)) {
                         add_xapian($self, $mime, $smsg, $mids);
@@ -611,9 +615,9 @@ sub read_log {
                         $latest = $1;
                         $newest ||= $latest;
                 } elsif ($line =~ /^author .*? ([0-9]+) [\-\+][0-9]+$/) {
-                        $self->{over}->{autime} = $self->{autime} = $1;
+                        $self->{autime} = $1;
                 } elsif ($line =~ /^committer .*? ([0-9]+) [\-\+][0-9]+$/) {
-                        $self->{over}->{cotime} = $self->{cotime} = $1;
+                        $self->{cotime} = $1;
                 }
         }
         close($log) or die "git log failed: \$?=$?";