]> git.ipfire.org Git - thirdparty/public-inbox.git/commitdiff
search: move QueryParser mappings to xh_args
authorEric Wong <e@80x24.org>
Sat, 10 Aug 2024 09:00:05 +0000 (09:00 +0000)
committerEric Wong <e@80x24.org>
Sat, 17 Aug 2024 17:36:15 +0000 (17:36 +0000)
These are stable per-search instance.  We'll also deduplicate
the strings in case multiple inboxes share the same mappings.

lib/PublicInbox/Search.pm
t/watch_indexheader.t

index bdf5591cd21e3232ba5d4bc5034e45d797ab5394..dfe0271b9a72822279fb1eed45d77a7edfe11462 100644 (file)
@@ -476,16 +476,7 @@ sub xh_opt ($$) {
        push @ret, '-t' if $opt->{threads};
        push @ret, '-T', $opt->{threadid} if defined $opt->{threadid};
        push @ret, '-O', $opt->{eidx_key} if defined $opt->{eidx_key};
-       my $apfx = $self->{-alt_pfx} //= do {
-               my @tmp;
-               for my $x (@{$self->{-extra} // []}) {
-                       my $sym = $QPMETHOD_2_SYM{$x->query_parser_method};
-                       push @tmp, '-Q', $x->{prefix}.$sym.$x->{xprefix};
-               }
-               # TODO: arbitrary header indexing goes here
-               \@tmp;
-       };
-       (@ret, @$apfx);
+       @ret;
 }
 
 # returns a true value if actually handled asynchronously,
@@ -730,7 +721,17 @@ sub all_terms {
 }
 
 sub xh_args { # prep getopt args to feed to xap_helper.h socket
-       map { ('-d', $_) } shard_dirs($_[0]);
+       my ($self) = @_;
+       my $apfx = $self->{-alt_pfx} //= do {
+               my %dedupe;
+               for my $x (@{$self->{-extra} // []}) {
+                       my $sym = $QPMETHOD_2_SYM{$x->query_parser_method};
+                       $dedupe{$x->{prefix}.$sym.$x->{xprefix}} = undef;
+               }
+               # TODO: arbitrary header indexing goes here
+               [ sort keys %dedupe ];
+       };
+       ((map { ('-d', $_) } shard_dirs($self)), map { ('-Q', $_) } @$apfx);
 }
 
 sub docids_by_postlist ($$) {
index e815fca964efddceef46b7417ebba53ceac3ae71..623698e739e361dc1f7a59cd394f56980b296c7c 100644 (file)
@@ -84,7 +84,7 @@ $cfg->each_inbox(sub {
        my $eml = $ibx->smsg_eml($ibx->over->get_art($num->[0]));
        is($eml->header_raw('X-Archives-Hash'), $h1,
                'stored message with X-Archives-Hash');
-       my @opt = $srch->xh_opt;
+       my @opt = $srch->xh_args;
        is $opt[-2], '-Q', 'xap_helper -Q switch';
        is $opt[-1], 'xarchiveshash=XXARCHIVESHASH', 'xap_helper -Q arg';
 });