* [PATCH] one-shot manifest.js.gz
@ 2024-04-07 9:43 Eric Wong
0 siblings, 0 replies; only message in thread
From: Eric Wong @ 2024-04-07 9:43 UTC (permalink / raw)
To: spew
---
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'} ?
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2024-04-07 9:43 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-07 9:43 [PATCH] one-shot manifest.js.gz Eric Wong
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).