From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-4.2 required=3.0 tests=ALL_TRUSTED,AWL,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF shortcircuit=no autolearn=ham autolearn_force=no version=3.4.6 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id C14CE1F44D for ; Sun, 7 Apr 2024 09:43:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=80x24.org; s=selector1; t=1712483026; bh=hl0sb/pwzX+a/Cn1Go8YiIYBTlB6oPtPVifCd3jgZcM=; h=From:To:Subject:Date:From; b=X9PFLXfG/5YDMQPD4qbbXzj55530IeoPfwGJEtXTaY4YlGUIql8TjTfNTkTX5Pnjk LsvG2PHolaV7bbNWe6IdKkH4iSAkUR/KEEnbg0kNcVu48csOXlsAmHgXNSNY6ES+93 OJqcHn6JWtLf1E7zOY3tYCTB+U1b6153STMwIccw= From: Eric Wong To: spew@80x24.org Subject: [PATCH] one-shot manifest.js.gz Date: Sun, 7 Apr 2024 09:43:46 +0000 Message-ID: <20240407094346.786532-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: --- lib/PublicInbox/ManifestJsGz.pm | 35 ++++++++++++++++++++++----------- lib/PublicInbox/WwwListing.pm | 27 ++++++++++++++----------- 2 files changed, 40 insertions(+), 22 deletions(-) diff --git a/lib/PublicInbox/ManifestJsGz.pm b/lib/PublicInbox/ManifestJsGz.pm index 1f739baa..6b6aa528 100644 --- a/lib/PublicInbox/ManifestJsGz.pm +++ b/lib/PublicInbox/ManifestJsGz.pm @@ -73,18 +73,31 @@ sub eidx_manifest_add ($$$) { } } -sub response { - my ($class, $ctx) = @_; - bless $ctx, $class; - my ($re, undef) = $ctx->url_filter; - $re // return psgi_triple($ctx); - my $iter = PublicInbox::ConfigIter->new($ctx->{www}->{pi_cfg}, - $ctx->can('list_match_i'), $re, $ctx); - sub { - $ctx->{-wcb} = $_[0]; # HTTP server callback - $ctx->{env}->{'pi-httpd.async'} ? - $iter->event_step : $iter->each_section; +sub mf_misc_ibx { # MiscSearch->retry_reopen callback + my ($misc, $ctx, $re) = @_; + delete $ctx->{-list}; # reset if retried + my $opt = { + asc => 1, + relevance => -1, # order by docid ASC + limit => $misc->{xdb}->get_doccount, + }; + my $mset = $misc->mset('', $opt); + my $pi_cfg = $ctx->{www}->{pi_cfg}; + for my $mi ($mset->items) { + my $doc = $mi->get_document; + my ($eidx_key) = PublicInbox::Search::xap_terms('Q', $doc); + $eidx_key // next; + my $ibx = $pi_cfg->lookup_eidx_key($eidx_key) // next; + next if $ctx->hide_inbox($ibx, $re); + $ctx->ibx_entry($ibx, $misc->doc2ibx_cache_ent($doc)); } + $ctx->{-mset} = $mset; + psgi_triple($ctx); +} + +sub list_fast { # called by WwwListing->response + my ($ctx, $ALL, $re) = @_; + $ALL->misc->reopen->retry_reopen(\&mf_misc_ibx, $ctx, $re); } sub ibx_entry { diff --git a/lib/PublicInbox/WwwListing.pm b/lib/PublicInbox/WwwListing.pm index 2d6c74da..05736989 100644 --- a/lib/PublicInbox/WwwListing.pm +++ b/lib/PublicInbox/WwwListing.pm @@ -135,25 +135,30 @@ sub add_misc_ibx { # MiscSearch->retry_reopen callback psgi_triple($ctx); } +sub list_fast { + my ($ctx, $ALL, $re, $qs) = @_; + if ($ctx->{qp}->{a} && # "search all inboxes" + $ctx->{qp}->{'q'}) { + my $u = 'all/?q='.mid_escape($ctx->{qp}->{'q'}); + return [ 302, [ 'Location' => $u, + qw(Content-Type text/plain) ], + [ "Redirecting to $u\n" ] ]; + } + # FIXME: test this in t/ + $ALL->misc->reopen->retry_reopen(\&add_misc_ibx, $ctx, $re, $qs); +} + sub response { my ($class, $ctx) = @_; bless $ctx, $class; my ($re, $qs) = $ctx->url_filter; $re // return $ctx->psgi_triple; if (my $ALL = $ctx->{www}->{pi_cfg}->ALL) { # fast path - if ($ctx->{qp}->{a} && # "search all inboxes" - $ctx->{qp}->{'q'}) { - my $u = 'all/?q='.mid_escape($ctx->{qp}->{'q'}); - return [ 302, [ 'Location' => $u, - qw(Content-Type text/plain) ], - [ "Redirecting to $u\n" ] ]; - } - # FIXME: test this in t/ - $ALL->misc->reopen->retry_reopen(\&add_misc_ibx, - $ctx, $re, $qs); + $ctx->list_fast($ALL, $re, $qs); } else { # slow path, no [extindex "all"] configured my $iter = PublicInbox::ConfigIter->new($ctx->{www}->{pi_cfg}, - \&list_match_i, $re, $ctx); + $ctx->can('list_match_i'), + $re, $ctx); sub { $ctx->{-wcb} = $_[0]; # HTTP server callback $ctx->{env}->{'pi-httpd.async'} ?