]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/MiscSearch.pm
mm: min/max: return 0 instead of undef
[public-inbox.git] / lib / PublicInbox / MiscSearch.pm
index 8beb8349fea839a4a132298ec9001a6c1758fb52..48ef6914fe8be2d6ab82ab5498ac2a9a0f556462 100644 (file)
@@ -50,7 +50,7 @@ sub mi_qp_new ($) {
 }
 
 sub misc_enquire_once { # retry_reopen callback
-       my ($self, $qr, $opt) = @{$_[0]};
+       my ($self, $qr, $opt) = @_;
        my $eq = $PublicInbox::Search::X{Enquire}->new($self->{xdb});
        $eq->set_query($qr);
         my $desc = !$opt->{asc};
@@ -73,7 +73,26 @@ sub mset {
        $qs = 'type:inbox' if $qs eq '';
        my $qr = $qp->parse_query($qs, $PublicInbox::Search::QP_FLAGS);
        $opt->{relevance} = 1 unless exists $opt->{relevance};
-       retry_reopen($self, \&misc_enquire_once, [ $self, $qr, $opt ]);
+       retry_reopen($self, \&misc_enquire_once, $qr, $opt);
+}
+
+sub ibx_data_once {
+       my ($self, $ibx) = @_;
+       my $xdb = $self->{xdb};
+       my $eidx_key = $ibx->eidx_key; # may be {inboxdir}, so private
+       my $head = $xdb->postlist_begin('Q'.$eidx_key);
+       my $tail = $xdb->postlist_end('Q'.$eidx_key);
+       if ($head != $tail) {
+               my $doc = $xdb->get_document($head->get_docid);
+               $doc->get_data;
+       } else {
+               undef;
+       }
+}
+
+sub inbox_data {
+       my ($self, $ibx) = @_;
+       retry_reopen($self, \&ibx_data_once, $ibx);
 }
 
 1;