diff options
author | Eric Wong (Contractor, The Linux Foundation) <e@80x24.org> | 2018-04-03 11:09:09 +0000 |
---|---|---|
committer | Eric Wong (Contractor, The Linux Foundation) <e@80x24.org> | 2018-04-03 12:06:13 +0000 |
commit | b9534449ecce2c59bb4aebad6051f91c3116b187 (patch) | |
tree | b355db7453fb8916a8b480d35b2ea8fccee78844 /lib/PublicInbox/Over.pm | |
parent | f91753f00b760c0e06eb0384792e5b18bd99bb0f (diff) | |
download | public-inbox-b9534449ecce2c59bb4aebad6051f91c3116b187.tar.gz |
OFFSET in SQLite gets painful to deal with. Instead, rely on timestamps (from Received:) for pagination. This also sets us up for more precise Date searching in case we want it.
Diffstat (limited to 'lib/PublicInbox/Over.pm')
-rw-r--r-- | lib/PublicInbox/Over.pm | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/lib/PublicInbox/Over.pm b/lib/PublicInbox/Over.pm index a7fd1315..b230d44a 100644 --- a/lib/PublicInbox/Over.pm +++ b/lib/PublicInbox/Over.pm @@ -109,10 +109,26 @@ SELECT COUNT(num) $cond } sub recent { - my ($self, $opts) = @_; - my $msgs = do_get($self, <<'', $opts); -SELECT * FROM over WHERE num > 0 -ORDER BY ts DESC + my ($self, $opts, $after, $before) = @_; + my ($s, @v); + if (defined($before)) { + if (defined($after)) { + $s = 'num > 0 AND ts >= ? AND ts <= ? ORDER BY ts DESC'; + @v = ($after, $before); + } else { + $s = 'num > 0 AND ts <= ? ORDER BY ts DESC'; + @v = ($before); + } + } else { + if (defined($after)) { + $s = 'num > 0 AND ts >= ? ORDER BY ts ASC'; + @v = ($after); + } else { + $s = 'num > 0 ORDER BY ts DESC'; + } + } + my $msgs = do_get($self, <<"", $opts, @v); +SELECT * FROM over WHERE $s return $msgs unless wantarray; |