unofficial mirror of meta@public-inbox.org
 help / color / mirror / Atom feed
From: Eric Wong <e@80x24.org>
To: meta@public-inbox.org
Subject: [PATCH 1/2] www: improve topic view by scanning for ghosts
Date: Mon, 20 Jun 2016 07:22:23 +0000	[thread overview]
Message-ID: <20160620072224.23973-2-e@80x24.org> (raw)
In-Reply-To: <20160620072224.23973-1-e@80x24.org>

This should help avoid having too many fake top-level
messages in the topic view since we only have a partial
window for threading results.
---
 lib/PublicInbox/Search.pm    |  6 ++++++
 lib/PublicInbox/SearchMsg.pm |  2 +-
 lib/PublicInbox/View.pm      | 14 +++++++++++---
 3 files changed, 18 insertions(+), 4 deletions(-)

diff --git a/lib/PublicInbox/Search.pm b/lib/PublicInbox/Search.pm
index 856c8c1..8c0bab1 100644
--- a/lib/PublicInbox/Search.pm
+++ b/lib/PublicInbox/Search.pm
@@ -227,6 +227,12 @@ sub lookup_message {
 	$smsg;
 }
 
+sub lookup_mail { # no ghosts!
+	my ($self, $mid) = @_;
+	my $smsg = lookup_message($self, $mid);
+	PublicInbox::SearchMsg->load_doc($smsg->{doc});
+}
+
 sub find_unique_doc_id {
 	my ($self, $term, $value) = @_;
 
diff --git a/lib/PublicInbox/SearchMsg.pm b/lib/PublicInbox/SearchMsg.pm
index 28c2037..d41d243 100644
--- a/lib/PublicInbox/SearchMsg.pm
+++ b/lib/PublicInbox/SearchMsg.pm
@@ -35,7 +35,7 @@ sub get_val ($$) {
 
 sub load_doc {
 	my ($class, $doc) = @_;
-	my $data = $doc->get_data;
+	my $data = $doc->get_data or return;
 	my $ts = get_val($doc, &PublicInbox::Search::TS);
 	utf8::decode($data);
 	my ($subj, $from, $refs, $to, $cc) = split(/\n/, $data);
diff --git a/lib/PublicInbox/View.pm b/lib/PublicInbox/View.pm
index 006da8d..dfae44f 100644
--- a/lib/PublicInbox/View.pm
+++ b/lib/PublicInbox/View.pm
@@ -741,19 +741,27 @@ sub sort_ts {
 	} @_;
 }
 
+sub _tryload_ghost ($$) {
+	my ($srch, $node) = @_;
+	my $mid = $node->messageid;
+	my $smsg = $srch->lookup_mail($mid) or return;
+	$smsg->mini_mime;
+}
+
 # accumulate recent topics if search is supported
 # returns 1 if done, undef if not
 sub add_topic {
 	my ($state, $node, $level) = @_;
 	return unless $node;
 	my $child_adjust = 1;
-
-	if (my $x = $node->message) {
+	my $srch = $state->{srch};
+	my $x = $node->message || _tryload_ghost($srch, $node);
+	if ($x) {
 		$x = $x->header_obj;
 		my $subj;
 
 		$subj = $x->header('Subject');
-		$subj = $state->{srch}->subject_normalized($subj);
+		$subj = $srch->subject_normalized($subj);
 
 		if (++$state->{subjs}->{$subj} == 1) {
 			push @{$state->{order}}, [ $level, $subj ];

  reply	other threads:[~2016-06-20  7:22 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-20  7:22 [PATCH 0/2] better ghost handling Eric Wong
2016-06-20  7:22 ` Eric Wong [this message]
2016-06-20  7:22 ` [PATCH 2/2] nntp: use lookup_mail instead of lookup_message Eric Wong

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://public-inbox.org/README

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20160620072224.23973-2-e@80x24.org \
    --to=e@80x24.org \
    --cc=meta@public-inbox.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).