]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/SearchMsg.pm
search: index and allow searching by date-time
[public-inbox.git] / lib / PublicInbox / SearchMsg.pm
index f5510b8e6b6f79c657fb3938460f9e4100e89f67..3278802b8b6c683e7ec9627be52d1048fe3f2594 100644 (file)
@@ -9,13 +9,12 @@ use warnings;
 use PublicInbox::MID qw/mid_clean mid_mime/;
 use PublicInbox::Address;
 use PublicInbox::MsgTime qw(msg_timestamp msg_datestamp);
+use Time::Local qw(timegm);
 
 sub new {
        my ($class, $mime) = @_;
        my $doc = Search::Xapian::Document->new;
-       $doc->add_boolean_term('T' . 'mail');
-
-       bless { type => 'mail', doc => $doc, mime => $mime }, $class;
+       bless { doc => $doc, mime => $mime }, $class;
 }
 
 sub wrap {
@@ -46,12 +45,12 @@ sub to_doc_data {
                $self->cc,
                $oid,
                $mid0,
-               $self->ds,
                $self->{bytes},
                $self->{lines}
        );
 }
 
+
 sub load_from_data ($$) {
        my ($self) = $_[0]; # data = $_[1]
        (
@@ -66,7 +65,6 @@ sub load_from_data ($$) {
 
                $self->{blob},
                $self->{mid},
-               $self->{ds},
                $self->{bytes},
                $self->{lines}
        ) = split(/\n/, $_[1]);
@@ -76,7 +74,10 @@ sub load_expand {
        my ($self) = @_;
        my $doc = $self->{doc};
        my $data = $doc->get_data or return;
-       $self->{ts} = get_val($doc, &PublicInbox::Search::TS);
+       $self->{ts} = get_val($doc, PublicInbox::Search::TS());
+       my $dt = get_val($doc, PublicInbox::Search::DT());
+       my ($yyyy, $mon, $dd, $hh, $mm, $ss) = unpack('A4A2A2A2A2A2', $dt);
+       $self->{ds} = timegm($ss, $mm, $hh, $dd, $mon - 1, $yyyy);
        utf8::decode($data);
        load_from_data($self, $data);
        $self;
@@ -187,26 +188,4 @@ sub mid ($;$) {
 
 sub _extract_mid { mid_clean(mid_mime($_[0]->{mime})) }
 
-sub thread_id {
-       my ($self) = @_;
-       my $tid = $self->{thread};
-       return $tid if defined $tid;
-       $self->{thread} = _get_term_val($self, 'G', qr/\AG/); # *G*roup
-}
-
-# XXX: consider removing this, we can phrase match subject
-sub path {
-       my ($self) = @_;
-       my $path = $self->{path};
-       return $path if defined $path;
-       $self->{path} = _get_term_val($self, 'XPATH', qr/\AXPATH/); # path
-}
-
-sub type {
-       my ($self) = @_;
-       my $type = $self->{type};
-       return $type if defined $type;
-       $self->{type} = _get_term_val($self, 'T', qr/\AT/);
-}
-
 1;