diff options
author | Eric Wong <e@yhbt.net> | 2020-08-22 06:06:26 +0000 |
---|---|---|
committer | Eric Wong <e@yhbt.net> | 2020-08-23 00:14:02 +0000 |
commit | aad1b9e70529b78d3d7d62b0920ad82ca40f9592 (patch) | |
tree | 23c8ace1fbcb52bbf0cf00c0f7a83fa006ba99b5 /lib/PublicInbox/Over.pm | |
parent | ae546078c5696ac73ad9f48c2c90163febb4a246 (diff) | |
download | public-inbox-aad1b9e70529b78d3d7d62b0920ad82ca40f9592.tar.gz |
Finally, the addition of THREADID for collapsing results in Xapian lets us emulate the "mairix --threads" feature. That is, instead of returning only the matching messages, the entire thread is included in the downloaded mbox.gz This requires a "public-inbox-index --reindex" to be usable.
Diffstat (limited to 'lib/PublicInbox/Over.pm')
-rw-r--r-- | lib/PublicInbox/Over.pm | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/lib/PublicInbox/Over.pm b/lib/PublicInbox/Over.pm index 34d0b05d..fba58d17 100644 --- a/lib/PublicInbox/Over.pm +++ b/lib/PublicInbox/Over.pm @@ -179,6 +179,35 @@ ORDER BY $sort_col DESC ($nr, $msgs); } +# strict `tid' matches, only, for thread-expanded mbox.gz search results +# and future CLI interface +# returns true if we have IDs, undef if not +sub expand_thread { + my ($self, $ctx) = @_; + my $dbh = $self->connect; + do { + defined(my $num = $ctx->{ids}->[0]) or return; + my ($tid) = $dbh->selectrow_array(<<'', undef, $num); +SELECT tid FROM over WHERE num = ? + + if (defined($tid)) { + my $sql = <<''; +SELECT num FROM over WHERE tid = ? AND num > ? +ORDER BY num ASC LIMIT 1000 + + my $xids = $dbh->selectcol_arrayref($sql, undef, $tid, + $ctx->{prev} // 0); + if (scalar(@$xids)) { + $ctx->{prev} = $xids->[-1]; + $ctx->{xids} = $xids; + return 1; # success + } + } + $ctx->{prev} = 0; + shift @{$ctx->{ids}}; + } while (1); +} + sub recent { my ($self, $opts, $after, $before) = @_; my ($s, @v); |