about summary refs log tree commit homepage
path: root/lib/PublicInbox/View.pm
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2019-12-25 07:50:59 +0000
committerEric Wong <e@80x24.org>2019-12-27 20:00:37 +0000
commit9b5bf24a115346ef6095f4c613b4579fde112714 (patch)
tree4c5a9b52b95cfbff19a6156922223e1b9a421d41 /lib/PublicInbox/View.pm
parent2d2b53538f1121e98ddc0652e2749bb90ea97769 (diff)
downloadpublic-inbox-9b5bf24a115346ef6095f4c613b4579fde112714.tar.gz
We don't need to return a closure or have a separate hash
for sorting threads by relevance.  Instead, we can stuff
the relevance {pct} into the SearchMsg object itself and
use that.

Note: upon reviewing this code, the sort-by-relevance seems
bogus as it only considers the relevance of the topmost message.
Instead, it would make more sense to the user to sort by the
highest relevance of all messages in that particular thread.
Diffstat (limited to 'lib/PublicInbox/View.pm')
-rw-r--r--lib/PublicInbox/View.pm11
1 files changed, 5 insertions, 6 deletions
diff --git a/lib/PublicInbox/View.pm b/lib/PublicInbox/View.pm
index 5c64441a..6f827754 100644
--- a/lib/PublicInbox/View.pm
+++ b/lib/PublicInbox/View.pm
@@ -279,8 +279,8 @@ sub index_entry {
                 " <a\nhref=\"${mhref}#R\">reply</a>";
 
         my $hr;
-        if (my $pct = $ctx->{pct}) { # used by SearchView.pm
-                $rv .= "\t[relevance $pct->{$mid_raw}%]";
+        if (defined(my $pct = $smsg->{pct})) { # used by SearchView.pm
+                $rv .= "\t[relevance $pct%]";
                 $hr = 1;
         } elsif ($mapping) {
                 my $nested = 'nested';
@@ -961,9 +961,8 @@ sub skel_dump {
 
         my $d = fmt_ts($smsg->{ds});
         my $unmatched; # if lazy-loaded by SearchThread::Msg::visible()
-        if (my $pct = $ctx->{pct}) {
-                $pct = $pct->{$smsg->{mid}};
-                if (defined $pct) {
+        if (exists $ctx->{searchview}) {
+                if (defined(my $pct = $smsg->{pct})) {
                         $d .= (sprintf(' % 2u', $pct) . '%');
                 } else {
                         $unmatched = 1;
@@ -1031,7 +1030,7 @@ sub _skel_ghost {
 
         my $mid = $node->{id};
         my $d = '     [not found] ';
-        $d .= '    '  if exists $ctx->{pct};
+        $d .= '    '  if exists $ctx->{searchview};
         $d .= indent_for($level) . th_pfx($level);
         my $upfx = $ctx->{-upfx};
         my $m = PublicInbox::Hval->new_msgid($mid);