diff options
author | Eric Wong (Contractor, The Linux Foundation) <e@80x24.org> | 2018-04-06 21:44:38 +0000 |
---|---|---|
committer | Eric Wong (Contractor, The Linux Foundation) <e@80x24.org> | 2018-04-06 21:45:03 +0000 |
commit | fad9acd35e56a289ade90a62d056b2a6663d448c (patch) | |
tree | 74d3203af13690a521d4de54ca2733223e2c389e /lib/PublicInbox/Over.pm | |
parent | 8f2999546c9447ce2aed48ba4d1192e0058e28a2 (diff) | |
download | public-inbox-fad9acd35e56a289ade90a62d056b2a6663d448c.tar.gz |
Favor simpler internal APIs this time around, this cuts a fair amount of code out and takes another step towards removing Xapian as a dependency for v2 repos.
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 0bd6008b..309e044a 100644 --- a/lib/PublicInbox/Over.pm +++ b/lib/PublicInbox/Over.pm @@ -147,4 +147,33 @@ SELECT * from OVER where num = ? LIMIT 1 undef; } +sub next_by_mid { + my ($self, $mid, $id, $prev) = @_; + my $dbh = $self->connect; + + unless (defined $$id) { + my $sth = $dbh->prepare_cached(<<'', undef, 1); + SELECT id FROM msgid WHERE mid = ? LIMIT 1 + + $sth->execute($mid); + $$id = $sth->fetchrow_array; + defined $$id or return; + } + my $sth = $dbh->prepare_cached(<<"", undef, 1); +SELECT num FROM id2num WHERE id = ? AND num > ? +ORDER BY num ASC LIMIT 1 + + $$prev ||= 0; + $sth->execute($$id, $$prev); + my $num = $sth->fetchrow_array or return; + $$prev = $num; + + $sth = $dbh->prepare_cached(<<"", undef, 1); +SELECT num,ts,ds,ddd FROM over WHERE num = ? LIMIT 1 + + $sth->execute($num); + my $smsg = $sth->fetchrow_hashref or return; + load_from_row($smsg); +} + 1; |