]> Sergey Matveev's repositories - public-inbox.git/commitdiff
search: always sort thread results in ascending time order
authorEric Wong <e@80x24.org>
Sat, 10 Dec 2016 01:09:51 +0000 (01:09 +0000)
committerEric Wong <e@80x24.org>
Sat, 10 Dec 2016 03:29:07 +0000 (03:29 +0000)
This makes life easier for the threading algorithm, as we can
use the implied ordering of timestamps to avoid temporary ghosts
and resulting container vivication.

This would've also allowed us to hide the bug (in most cases)
fixed by the patch titled "thread: last Reference always wins",
in case that needs to be reverted due to infinite looping.

lib/PublicInbox/Mbox.pm
lib/PublicInbox/Search.pm
lib/PublicInbox/View.pm

index fd623f6d48bd4e63ae3fc8d762e5a75fed39f993..2565ea58a07d327b94c8947ceb705427c17fc0fb 100644 (file)
@@ -115,7 +115,7 @@ sub new {
                cb => $cb,
                ctx => $ctx,
                msgs => [],
-               opts => { asc => 1, offset => 0 },
+               opts => { offset => 0 },
        }, $class;
 }
 
index 8da30c19c9d87661e4f4a0b7f8435f1d69d59c81..5e6bfc68bdb3d20985ffc177660b270c6ed3cd09 100644 (file)
@@ -158,6 +158,11 @@ sub get_thread {
        }
        $opts ||= {};
        $opts->{limit} ||= 1000;
+
+       # always sort threads by timestamp, this makes life easier
+       # for the threading algorithm (in SearchThread.pm)
+       $opts->{asc} = 1;
+
        _do_enquire($self, $qtid, $opts);
 }
 
index c2e1ae76a400aef4395fc77641c23fe37668e3a1..ec5f7e0f162b57359714ac90bd6590fb43728420 100644 (file)
@@ -327,7 +327,7 @@ sub stream_thread ($$) {
 sub thread_html {
        my ($ctx) = @_;
        my $mid = $ctx->{mid};
-       my $sres = $ctx->{srch}->get_thread($mid, { asc => 1 });
+       my $sres = $ctx->{srch}->get_thread($mid);
        my $msgs = load_results($sres);
        my $nr = $sres->{total};
        return missing_thread($ctx) if $nr == 0;