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 E6E9E209C6 for ; Wed, 5 Oct 2016 23:57:27 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 13/17] thread: fix sorting without topmost Date: Wed, 5 Oct 2016 23:57:18 +0000 Message-Id: <20161005235722.14857-14-e@80x24.org> In-Reply-To: <20161005235722.14857-1-e@80x24.org> References: <20161005235722.14857-1-e@80x24.org> List-Id: This bug was hidden, and we may not be able to efficiently implement a topmost subroutine with the hash-based (vs linked-list) based container for threading in the next commit. --- lib/PublicInbox/SearchView.pm | 5 ++--- lib/PublicInbox/View.pm | 4 ++-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/lib/PublicInbox/SearchView.pm b/lib/PublicInbox/SearchView.pm index ebeb41f..cfe6dff 100644 --- a/lib/PublicInbox/SearchView.pm +++ b/lib/PublicInbox/SearchView.pm @@ -155,9 +155,8 @@ sub mset_thread { $th->thread; if ($q->{r}) { # order by relevance $th->order(sub { - [ sort { (eval { $pct{$b->topmost->{id}} } || 0) - <=> - (eval { $pct{$a->topmost->{id}} } || 0) + [ sort { ( $pct{$b->{id}} || 0) <=> + ( $pct{$a->{id}} || 0) } @{$_[0]} ]; }); } else { # order by time (default for threaded view) diff --git a/lib/PublicInbox/View.pm b/lib/PublicInbox/View.pm index 7554d54..c09b4a2 100644 --- a/lib/PublicInbox/View.pm +++ b/lib/PublicInbox/View.pm @@ -857,8 +857,8 @@ sub skel_dump { sub sort_ts { [ sort { - (eval { $a->topmost->{smsg}->ts } || 0) <=> - (eval { $b->topmost->{smsg}->ts } || 0) + (eval { $a->{smsg}->ts } || 0) <=> + (eval { $b->{smsg}->ts } || 0) } @{$_[0]} ]; } -- EW