use warnings;
# values for searching
-use constant TS => 0; # timestamp
+use constant DS => 0; # Date: header in Unix time
use constant NUM => 1; # NNTP article number
use constant BYTES => 2; # :bytes as defined in RFC 3977
use constant LINES => 3; # :lines as defined in RFC 3977
-use constant YYYYMMDD => 4; # for searching in the WWW UI
+use constant TS => 4; # Received: header in Unix time
+use constant YYYYMMDD => 5; # for searching in the WWW UI
use Search::Xapian qw/:standard/;
use PublicInbox::SearchMsg;
if (my $skel = $self->{skel}) {
$skel->reopen;
}
+ $self; # make chaining easier
}
# read-only
_do_enquire($self, $query, $opts);
}
+sub query_ts {
+ my ($self, $ts, $opts) = @_;
+ my $qp = $self->{qp_ts} ||= eval {
+ my $q = Search::Xapian::QueryParser->new;
+ $q->set_database($self->{skel} || $self->{xdb});
+ $q->add_valuerangeprocessor(
+ Search::Xapian::NumberValueRangeProcessor->new(TS));
+ $q
+ };
+ my $query = $qp->parse_query($ts, QP_FLAGS);
+ $opts->{enquire} = enquire_skel($self);
+ _do_enquire($self, $query, $opts);
+}
+
sub lookup_skeleton {
my ($self, $mid) = @_;
my $skel = $self->{skel} or return lookup_message($self, $mid);
sub lookup_mail { # no ghosts!
my ($self, $mid) = @_;
retry_reopen($self, sub {
- my $smsg = lookup_message($self, $mid) or return;
+ my $smsg = lookup_skeleton($self, $mid) or return;
$smsg->load_expand;
});
}
sub each_smsg_by_mid {
my ($self, $mid, $cb) = @_;
- my $xdb = $self->{xdb};
# XXX retry_reopen isn't necessary for V2Writable, but the PSGI
# interface will need it...
- my ($head, $tail) = $self->find_doc_ids('Q' . $mid);
+ my $db = $self->{skel} || $self->{xdb};
+ my $term = 'Q' . $mid;
+ my $head = $db->postlist_begin($term);
+ my $tail = $db->postlist_end($term);
+ if ($head == $tail) {
+ $db->reopen;
+ $head = $db->postlist_begin($term);
+ $tail = $db->postlist_end($term);
+ }
+ return ($head, $tail, $db) if wantarray;
for (; $head->nequal($tail); $head->inc) {
my $doc_id = $head->get_docid;
- my $doc = $xdb->get_document($doc_id);
+ my $doc = $db->get_document($doc_id);
my $smsg = PublicInbox::SearchMsg->wrap($doc, $mid);
$smsg->{doc_id} = $doc_id;
$cb->($smsg) or return;