From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-4.0 required=3.0 tests=ALL_TRUSTED,BAYES_00 shortcircuit=no autolearn=ham autolearn_force=no version=3.4.0 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 7FB21209C1 for ; Sat, 10 Dec 2016 03:43:07 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 7/7] search: always sort thread results in ascending time order Date: Sat, 10 Dec 2016 03:43:05 +0000 Message-Id: <20161210034305.2654-8-e@80x24.org> In-Reply-To: <20161210034305.2654-1-e@80x24.org> References: <20161210034305.2654-1-e@80x24.org> List-Id: 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 | 2 +- lib/PublicInbox/Search.pm | 5 +++++ lib/PublicInbox/View.pm | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/PublicInbox/Mbox.pm b/lib/PublicInbox/Mbox.pm index fd623f6..2565ea5 100644 --- a/lib/PublicInbox/Mbox.pm +++ b/lib/PublicInbox/Mbox.pm @@ -115,7 +115,7 @@ sub new { cb => $cb, ctx => $ctx, msgs => [], - opts => { asc => 1, offset => 0 }, + opts => { offset => 0 }, }, $class; } diff --git a/lib/PublicInbox/Search.pm b/lib/PublicInbox/Search.pm index 8da30c1..5e6bfc6 100644 --- a/lib/PublicInbox/Search.pm +++ b/lib/PublicInbox/Search.pm @@ -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); } diff --git a/lib/PublicInbox/View.pm b/lib/PublicInbox/View.pm index c2e1ae7..ec5f7e0 100644 --- a/lib/PublicInbox/View.pm +++ b/lib/PublicInbox/View.pm @@ -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; -- EW