diff options
author | Eric Wong (Contractor, The Linux Foundation) <e@80x24.org> | 2018-04-03 11:09:12 +0000 |
---|---|---|
committer | Eric Wong (Contractor, The Linux Foundation) <e@80x24.org> | 2018-04-03 12:06:17 +0000 |
commit | b8c41362f2a5c8fcc6b1846a79c72bfa77565297 (patch) | |
tree | 478667e1ca0d300260427e5499ff0a692b25913f /lib/PublicInbox/Msgmap.pm | |
parent | 445d2062a60959a04b55d7d1fe4439eff23cd44d (diff) | |
download | public-inbox-b8c41362f2a5c8fcc6b1846a79c72bfa77565297.tar.gz |
We we worked around the default range/termination conditions of long_response in many cases to reduce calls to SQLite or Xapian. So continue that trend and become more like the PSGI API which doesn't force callers to specify an article range or work inside a loop.
Diffstat (limited to 'lib/PublicInbox/Msgmap.pm')
-rw-r--r-- | lib/PublicInbox/Msgmap.pm | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/lib/PublicInbox/Msgmap.pm b/lib/PublicInbox/Msgmap.pm index 26565d45..c6a73155 100644 --- a/lib/PublicInbox/Msgmap.pm +++ b/lib/PublicInbox/Msgmap.pm @@ -196,6 +196,18 @@ ORDER BY num ASC LIMIT 1000 $ids; } +sub msg_range { + my ($self, $beg, $end) = @_; + my $dbh = $self->{dbh}; + my $attr = { Columns => [] }; + my $mids = $dbh->selectall_arrayref(<<'', $attr, $$beg, $end); +SELECT num,mid FROM msgmap WHERE num >= ? AND num <= ? +ORDER BY num ASC + + $$beg = $mids->[-1]->[0] + 1 if @$mids; + $mids +} + # only used for mapping external serial numbers (e.g. articles from gmane) # see scripts/xhdr-num2mid or PublicInbox::Filter::RubyLang for usage sub mid_set { |