From 56cdc78884fdc7378c727d9aa8861acbc56940f9 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Fri, 9 Jun 2023 10:31:07 +0000 Subject: search: hoist out do_enquire for codesearch 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/Search.pm | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'lib/PublicInbox/Search.pm') 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 -- cgit v1.2.3-24-ge0c7