X-Git-Url: http://www.git.stargrave.org/?a=blobdiff_plain;f=lib%2FPublicInbox%2FSearchView.pm;h=0d2e71fda534d4819ae23813516d4df9b74f7c45;hb=55b707d788ce13696e4411389583e720ea6dab01;hp=8cffdedbb33a27dce981fd4d503776de75c1b62d;hpb=9b5bf24a115346ef6095f4c613b4579fde112714;p=public-inbox.git diff --git a/lib/PublicInbox/SearchView.pm b/lib/PublicInbox/SearchView.pm index 8cffdedb..0d2e71fd 100644 --- a/lib/PublicInbox/SearchView.pm +++ b/lib/PublicInbox/SearchView.pm @@ -10,10 +10,7 @@ use PublicInbox::SearchMsg; use PublicInbox::Hval qw/ascii_html obfuscate_addrs/; use PublicInbox::View; use PublicInbox::WwwAtomStream; -use PublicInbox::MID qw(MID_ESC); -use PublicInbox::MIME; -require PublicInbox::Git; -require PublicInbox::SearchThread; +use PublicInbox::SearchThread; our $LIM = 200; my %rmap_inc; @@ -88,17 +85,6 @@ retry: PublicInbox::WwwStream->response($ctx, $code, $cb); } -# allow undef for individual doc loads... -sub load_doc_retry { - my ($srch, $mitem) = @_; - - eval { - $srch->retry_reopen(sub { - PublicInbox::SearchMsg->load_doc($mitem->get_document) - }); - } -} - # display non-nested search results similar to what users expect from # regular WWW search engines: sub mset_summary { @@ -114,7 +100,7 @@ sub mset_summary { foreach my $m ($mset->items) { my $rank = sprintf("%${pad}d", $m->get_rank + 1); my $pct = get_pct($m); - my $smsg = load_doc_retry($srch, $m); + my $smsg = PublicInbox::SearchMsg::from_mitem($m, $srch); unless ($smsg) { eval { $m = "$m ".$m->get_docid . " expired\n"; @@ -270,14 +256,19 @@ sub get_pct ($) { $n > 99 ? 99 : $n; } +sub load_msgs { + my ($mset) = @_; + [ map { + my $mi = $_; + my $smsg = PublicInbox::SearchMsg::from_mitem($mi); + $smsg->{pct} = get_pct($mi); + $smsg; + } ($mset->items) ] +} + sub mset_thread { my ($ctx, $mset, $q) = @_; - my $msgs = $ctx->{-inbox}->search->retry_reopen(sub { [ map { - my $i = $_; - my $smsg = PublicInbox::SearchMsg->load_doc($i->get_document); - $smsg->{pct} = get_pct($i); - $smsg; - } ($mset->items) ]}); + my $msgs = $ctx->{-inbox}->search->retry_reopen(\&load_msgs, $mset); my $r = $q->{r}; my $rootset = PublicInbox::SearchThread::thread($msgs, $r ? \&sort_relevance : \&PublicInbox::View::sort_ds, @@ -345,7 +336,9 @@ sub adump { sub adump_i { my ($ctx) = @_; while (my $mi = shift @{$ctx->{items}}) { - my $smsg = load_doc_retry($ctx->{srch}, $mi) or next; + my $smsg = eval { + PublicInbox::SearchMsg::from_mitem($mi, $ctx->{srch}); + } or next; $ctx->{-inbox}->smsg_mime($smsg) and return $smsg; } } @@ -354,7 +347,6 @@ package PublicInbox::SearchQuery; use strict; use warnings; use URI::Escape qw(uri_escape); -use PublicInbox::Hval; use PublicInbox::MID qw(MID_ESC); sub new {