* [PATCH] searchview: save a column in &x=t thread skeleton
@ 2019-12-20 6:58 Eric Wong
0 siblings, 0 replies; only message in thread
From: Eric Wong @ 2019-12-20 6:58 UTC (permalink / raw)
To: meta
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.
---
lib/PublicInbox/SearchView.pm | 12 ++++++++++--
lib/PublicInbox/View.pm | 6 +++---
2 files changed, 13 insertions(+), 5 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};
diff --git a/lib/PublicInbox/View.pm b/lib/PublicInbox/View.pm
index 5924a2a7..0b102638 100644
--- a/lib/PublicInbox/View.pm
+++ b/lib/PublicInbox/View.pm
@@ -955,10 +955,10 @@ sub skel_dump {
if (my $pct = $ctx->{pct}) {
$pct = $pct->{$smsg->{mid}};
if (defined $pct) {
- $d .= (sprintf(' % 3u', $pct) . '%');
+ $d .= (sprintf(' % 2u', $pct) . '%');
} else {
$unmatched = 1;
- $d .= ' ';
+ $d .= ' ';
}
}
$d .= ' ' . indent_for($level) . th_pfx($level);
@@ -1022,7 +1022,7 @@ sub _skel_ghost {
my $mid = $node->{id};
my $d = ' [not found] ';
- $d .= ' ' if exists $ctx->{pct};
+ $d .= ' ' if exists $ctx->{pct};
$d .= indent_for($level) . th_pfx($level);
my $upfx = $ctx->{-upfx};
my $m = PublicInbox::Hval->new_msgid($mid);
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2019-12-20 6:58 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-20 6:58 [PATCH] searchview: save a column in &x=t thread skeleton Eric Wong
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).