* [PATCH 2/3] search: hoist out do_enquire for codesearch
2023-06-09 10:31 7% [PATCH 0/3] cindex association prep work Eric Wong
@ 2023-06-09 10:31 6% ` Eric Wong
0 siblings, 0 replies; 2+ results
From: Eric Wong @ 2023-06-09 10:31 UTC (permalink / raw)
To: meta
Reusing this bit seems to make sense as mail and code search
are similar enough w.r.t. setting up sort options. This
deduplication will become more useful as -cindex will
likely combine code and mail search to generate associations
between inboxes and code repos.
---
lib/PublicInbox/CodeSearch.pm | 11 +----------
lib/PublicInbox/Search.pm | 8 ++++++--
2 files changed, 7 insertions(+), 12 deletions(-)
diff --git a/lib/PublicInbox/CodeSearch.pm b/lib/PublicInbox/CodeSearch.pm
index 1dfc124f..a5ccce03 100644
--- a/lib/PublicInbox/CodeSearch.pm
+++ b/lib/PublicInbox/CodeSearch.pm
@@ -106,16 +106,7 @@ sub mset {
$qry = $PublicInbox::Search::X{Query}->new(
PublicInbox::Search::OP_FILTER(),
$qry, 'T'.'c');
-
- my $enq = $PublicInbox::Search::X{Enquire}->new($self->xdb);
- $enq->set_query($qry);
- if ($opt->{relevance}) {
- $enq->set_sort_by_relevance_then_value(CT, !$opt->{asc});
- } else {
- $enq->set_sort_by_value_then_relevance(CT, !$opt->{asc});
- }
- $self->retry_reopen($self->can('enquire_once'), $enq,
- $opt->{offset} || 0, $opt->{limit} || 50);
+ $self->do_enquire($qry, $opt, CT);
}
1;
diff --git a/lib/PublicInbox/Search.pm b/lib/PublicInbox/Search.pm
index 6986cb88..a4fef17b 100644
--- a/lib/PublicInbox/Search.pm
+++ b/lib/PublicInbox/Search.pm
@@ -390,7 +390,11 @@ sub mset {
$qry = $X{Query}->new(OP_FILTER(), $qry,
$X{Query}->new(OP_VALUE_RANGE(), THREADID, $tid, $tid));
}
+ do_enquire($self, $qry, $opt, TS);
+}
+sub do_enquire { # shared with CodeSearch
+ my ($self, $qry, $opt, $col) = @_;
my $enq = $X{Enquire}->new(xdb($self));
$enq->set_query($qry);
my $rel = $opt->{relevance} // 0;
@@ -401,9 +405,9 @@ sub mset {
$enq->set_weighting_scheme($X{BoolWeight}->new);
$enq->set_docid_order($ENQ_ASCENDING);
} elsif ($rel == 0) {
- $enq->set_sort_by_value_then_relevance(TS, !$opt->{asc});
+ $enq->set_sort_by_value_then_relevance($col, !$opt->{asc});
} else { # rel > 0
- $enq->set_sort_by_relevance_then_value(TS, !$opt->{asc});
+ $enq->set_sort_by_relevance_then_value($col, !$opt->{asc});
}
# `lei q -t / --threads' or JMAP collapseThreads; but don't collapse
^ permalink raw reply related [relevance 6%]
* [PATCH 0/3] cindex association prep work
@ 2023-06-09 10:31 7% Eric Wong
2023-06-09 10:31 6% ` [PATCH 2/3] search: hoist out do_enquire for codesearch Eric Wong
0 siblings, 1 reply; 2+ results
From: Eric Wong @ 2023-06-09 10:31 UTC (permalink / raw)
To: meta
Automated JOINs of coderepos + inboxes is finally coming
together, and this series starts laying out the groundwork for
some of it...
The prospect of waiting until 2030 (or likely later) until
we can rely on users having List::Util::{uniq,uniqstr} is
pretty depressing. However, isolating that stuff into
PublicInbox::Compat means we can more easily things which
will eventually go away on our end, even if it's decades
from now...
Eric Wong (3):
search: add comments wrt codesearch, reduce ops
search: hoist out do_enquire for codesearch
add compat package for List::Util::uniqstr
MANIFEST | 1 +
lib/PublicInbox/CodeSearch.pm | 11 +-------
lib/PublicInbox/CodeSearchIdx.pm | 7 +++--
lib/PublicInbox/Compat.pm | 24 +++++++++++++++++
lib/PublicInbox/Inbox.pm | 10 +++-----
lib/PublicInbox/LeiImport.pm | 4 +--
lib/PublicInbox/LeiImportKw.pm | 4 +--
lib/PublicInbox/LeiMailSync.pm | 17 ++++++------
lib/PublicInbox/Search.pm | 44 ++++++++++++++++----------------
lib/PublicInbox/SolverGit.pm | 4 +--
10 files changed, 68 insertions(+), 58 deletions(-)
create mode 100644 lib/PublicInbox/Compat.pm
^ permalink raw reply [relevance 7%]
Results 1-2 of 2 | reverse | options above
-- pct% links below jump to the message on this page, permalinks otherwise --
2023-06-09 10:31 7% [PATCH 0/3] cindex association prep work Eric Wong
2023-06-09 10:31 6% ` [PATCH 2/3] search: hoist out do_enquire for codesearch Eric Wong
Code repositories for project(s) associated with this public inbox
https://80x24.org/public-inbox.git
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).