From: Eric Wong <e@80x24.org>
To: spew@80x24.org
Subject: [PATCH] one-shot manifest.js.gz
Date: Sun, 7 Apr 2024 09:43:46 +0000 [thread overview]
Message-ID: <20240407094346.786532-1-e@80x24.org> (raw)
---
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'} ?
reply other threads:[~2024-04-07 9:43 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240407094346.786532-1-e@80x24.org \
--to=e@80x24.org \
--cc=spew@80x24.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).