]> Sergey Matveev's repositories - public-inbox.git/commitdiff
search: remove subject_summary
authorEric Wong <e@80x24.org>
Sat, 7 Jan 2017 01:44:52 +0000 (01:44 +0000)
committerEric Wong <e@80x24.org>
Sat, 7 Jan 2017 01:45:46 +0000 (01:45 +0000)
Apparently it never actually got used, and the world seems
fine without it, so we can drop it.

While we're at it, consider removing our subject_path
usage from existence, too.  We are not using fancy subject-line
based URLs, here.

lib/PublicInbox/Search.pm
lib/PublicInbox/SearchMsg.pm
t/search.t

index 86354b571f88541fe2d271c92c220204a151bf97..a1bae4197e65d5093c6d938d40da474c94a9ad09 100644 (file)
@@ -326,6 +326,7 @@ sub find_doc_ids_for_term {
 }
 
 # normalize subjects so they are suitable as pathnames for URLs
+# XXX: consider for removal
 sub subject_path {
        my $subj = pop;
        $subj = subject_normalized($subj);
@@ -343,32 +344,6 @@ sub subject_normalized {
        $subj;
 }
 
-# for doc data
-sub subject_summary {
-       my $subj = pop;
-       my $max = 68;
-       if (length($subj) > $max) {
-               my @subj = split(/\s+/, $subj);
-               $subj = '';
-               my $l;
-
-               while ($l = shift @subj) {
-                       my $new = $subj . $l . ' ';
-                       last if length($new) >= $max;
-                       $subj = $new;
-               }
-               if ($subj ne '') {
-                       my $r = scalar @subj ? ' ...' : '';
-                       $subj =~ s/ \z/$r/s;
-               } else {
-                       # subject has one REALLY long word, and NOT spam? wtf
-                       @subj = ($l =~ /\A(.{1,72})/);
-                       $subj = $subj[0] . ' ...';
-               }
-       }
-       $subj;
-}
-
 sub enquire {
        my ($self) = @_;
        $self->{enquire} ||= Search::Xapian::Enquire->new($self->{xdb});
index 5bb00778f1472712d1d609d72bda75125fea3ad0..b8eee6651b47fe748275b37e237f794302311c38 100644 (file)
@@ -155,6 +155,7 @@ sub thread_id {
        $self->{thread} = _get_term_val($self, 'G', qr/\AG/); # *G*roup
 }
 
+# XXX: consider removing this, we can phrase match subject
 sub path {
        my ($self) = @_;
        my $path = $self->{path};
index c16811d8d462806886c5d6f06e54d09c8dd0f6ba..c9c4e3464ce1a1a83ca8d4af1518b0dbb57faeb5 100644 (file)
@@ -15,23 +15,6 @@ is(0, system(qw(git init -q --bare), $git_dir), "git init (main)");
 eval { PublicInbox::Search->new($git_dir) };
 ok($@, "exception raised on non-existent DB");
 
-{
-       my $orig = "FOO " x 30;
-       my $summ = PublicInbox::Search::subject_summary($orig);
-
-       $summ = length($summ);
-       $orig = length($orig);
-       ok($summ < $orig && $summ > 0, "summary shortened ($orig => $summ)");
-
-       $orig = "FOO" x 30;
-       $summ = PublicInbox::Search::subject_summary($orig);
-
-       $summ = length($summ);
-       $orig = length($orig);
-       ok($summ < $orig && $summ > 0,
-          "summary shortened but not empty: $summ");
-}
-
 my $rw = PublicInbox::SearchIdx->new($git_dir, 1);
 $rw->_xdb_acquire;
 $rw->_xdb_release;