diff options
author | Eric Wong <e@80x24.org> | 2019-12-20 06:58:27 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2019-12-21 05:42:44 +0000 |
commit | 5c46cd1b3aa2421ef1e1b794b1c2358898cdf37a (patch) | |
tree | 9bfa152280e48c7d43ed5970615797c2c175c334 /lib/PublicInbox/SearchView.pm | |
parent | f6f0cfb7f3b673f05a95e8c9c3bc7d31580feadc (diff) | |
download | public-inbox-5c46cd1b3aa2421ef1e1b794b1c2358898cdf37a.tar.gz |
searchview: save a column in &x=t thread skeleton
Displaying "100%" wastes a precious column. Show "99%" instead since there's little practical difference and <xapian/mset.h> states: Note that these generally aren't percentages of anything meaningful (unless you use a custom weighting formula where they are!) And we're not using a custom weighting formula.
Diffstat (limited to 'lib/PublicInbox/SearchView.pm')
-rw-r--r-- | lib/PublicInbox/SearchView.pm | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/lib/PublicInbox/SearchView.pm b/lib/PublicInbox/SearchView.pm index 566808e1..7afb0754 100644 --- a/lib/PublicInbox/SearchView.pm +++ b/lib/PublicInbox/SearchView.pm @@ -113,7 +113,7 @@ sub mset_summary { my $obfs_ibx = $ibx->{obfuscate} ? $ibx : undef; foreach my $m ($mset->items) { my $rank = sprintf("%${pad}d", $m->get_rank + 1); - my $pct = $m->get_percent; + my $pct = get_pct($m); my $smsg = load_doc_retry($srch, $m); unless ($smsg) { eval { @@ -264,6 +264,14 @@ sub sort_relevance { } @{$_[0]} ] }; } +sub get_pct ($) { + # Capped at "99%" since "100%" takes an extra column in the + # thread skeleton view. <xapian/mset.h> says the value isn't + # very meaningful, anyways. + my $n = $_[0]->get_percent; + $n > 99 ? 99 : $n; +} + sub mset_thread { my ($ctx, $mset, $q) = @_; my %pct; @@ -271,7 +279,7 @@ sub mset_thread { my $msgs = $ibx->search->retry_reopen(sub { [ map { my $i = $_; my $smsg = PublicInbox::SearchMsg->load_doc($i->get_document); - $pct{$smsg->mid} = $i->get_percent; + $pct{$smsg->mid} = get_pct($i); $smsg; } ($mset->items) ]}); my $r = $q->{r}; |