user/dev discussion of public-inbox itself
 help / color / mirror / code / Atom feed
* [PATCH 1/2] feed: sort child messages (forward) chronologically
@ 2014-09-07 22:58 Eric Wong
  2014-09-07 22:58 ` [PATCH 2/2] feed: (cleanup) avoid redundant ->message call Eric Wong
  0 siblings, 1 reply; 2+ messages in thread
From: Eric Wong @ 2014-09-07 22:58 UTC (permalink / raw)
  To: meta; +Cc: Eric Wong

Only root messages should be sorted in reverse chronological order,
child messages should be chronological.  This gives precedence to
_topics_, but also for initial replies.

This improves readability when several messages appear at the same
nesting level, and helps git patch series' appear correctly as:

	[PATCH 0/3] ...
		[PATCH 1/3] ...
		[PATCH 2/3] ...
		[PATCH 3/3] ...

Instead of (what it was previously):

	[PATCH 0/3] ...
		[PATCH 3/3] ...
		[PATCH 2/3] ...
		[PATCH 1/3] ...
---
 lib/PublicInbox/Feed.pm | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/lib/PublicInbox/Feed.pm b/lib/PublicInbox/Feed.pm
index 646c85c..1f1c0d6 100644
--- a/lib/PublicInbox/Feed.pm
+++ b/lib/PublicInbox/Feed.pm
@@ -77,15 +77,21 @@ sub generate_html_index {
 		$feed_opts->{atomurl} . '" type="application/atom+xml"/>' .
 		'</head><body>' . PRE_WRAP;
 
-	# sort by date, most recent at top
+	# sort child messages in chronological order
 	$th->order(sub {
 		sort {
-			$b->topmost->message->header('X-PI-Date') <=>
-			$a->topmost->message->header('X-PI-Date')
+			$a->topmost->message->header('X-PI-Date') <=>
+			$b->topmost->message->header('X-PI-Date')
 		} @_;
 	});
+
 	my %seen;
-	dump_msg($_, 0, \$html, time, \%seen) for $th->rootset;
+	# except we sort top-level messages reverse chronologically
+	for (sort { (eval { $b->message->header('X-PI-Date') } || 0) <=>
+		    (eval { $a->message->header('X-PI-Date') } || 0)
+		  } $th->rootset) {
+		dump_msg($_, 0, \$html, time, \%seen);
+	}
 
 	Email::Address->purge_cache;
 
-- 
EW


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [PATCH 2/2] feed: (cleanup) avoid redundant ->message call
  2014-09-07 22:58 [PATCH 1/2] feed: sort child messages (forward) chronologically Eric Wong
@ 2014-09-07 22:58 ` Eric Wong
  0 siblings, 0 replies; 2+ messages in thread
From: Eric Wong @ 2014-09-07 22:58 UTC (permalink / raw)
  To: meta; +Cc: Eric Wong

Avoid redundant subroutine calls as their costs tend to add up.
---
 lib/PublicInbox/Feed.pm | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/PublicInbox/Feed.pm b/lib/PublicInbox/Feed.pm
index 1f1c0d6..350cc65 100644
--- a/lib/PublicInbox/Feed.pm
+++ b/lib/PublicInbox/Feed.pm
@@ -286,8 +286,8 @@ sub add_to_feed {
 
 sub dump_msg {
 	my ($self, $level, $html, $now, $seen) = @_;
-	if ($self->message) {
-		my $mime = $self->message;
+	my $mime = $self->message;
+	if ($mime) {
 		$$html .=
 		    PublicInbox::View->index_entry($mime, $now, $level, $seen);
 	}
-- 
EW


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-09-07 22:58 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-09-07 22:58 [PATCH 1/2] feed: sort child messages (forward) chronologically Eric Wong
2014-09-07 22:58 ` [PATCH 2/2] feed: (cleanup) avoid redundant ->message call Eric Wong

Code repositories for project(s) associated with this public inbox

	https://80x24.org/public-inbox.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).