diff options
author | Eric Wong (Contractor, The Linux Foundation) <e@80x24.org> | 2018-04-03 11:09:11 +0000 |
---|---|---|
committer | Eric Wong (Contractor, The Linux Foundation) <e@80x24.org> | 2018-04-03 12:06:15 +0000 |
commit | 445d2062a60959a04b55d7d1fe4439eff23cd44d (patch) | |
tree | 653eea288da968a04561224bc1ba079ed644ded3 /lib/PublicInbox/Msgmap.pm | |
parent | 0dceebd0a85774c92af247e6da5e2f5a0ee8417c (diff) | |
download | public-inbox-445d2062a60959a04b55d7d1fe4439eff23cd44d.tar.gz |
id_batch had a an overly complicated interface, replace it with id_batch which is simpler and takes advantage of selectcol_arrayref in DBI. This allows simplification of callers and the diffstat agrees with me.
Diffstat (limited to 'lib/PublicInbox/Msgmap.pm')
-rw-r--r-- | lib/PublicInbox/Msgmap.pm | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/lib/PublicInbox/Msgmap.pm b/lib/PublicInbox/Msgmap.pm index dea95731..26565d45 100644 --- a/lib/PublicInbox/Msgmap.pm +++ b/lib/PublicInbox/Msgmap.pm @@ -186,17 +186,14 @@ sub create_tables { } # used by NNTP.pm -sub id_batch { - my ($self, $num, $cb) = @_; - my $dbh = $self->{dbh}; - my $sth = $dbh->prepare('SELECT num FROM msgmap WHERE num > ? '. - 'ORDER BY num ASC LIMIT 1000'); - $sth->execute($num); - my $ary = $sth->fetchall_arrayref; - @$ary = map { $_->[0] } @$ary; - my $nr = scalar @$ary; - $cb->($ary) if $nr; - $nr; +sub ids_after { + my ($self, $num) = @_; + my $ids = $self->{dbh}->selectcol_arrayref(<<'', undef, $$num); +SELECT num FROM msgmap WHERE num > ? +ORDER BY num ASC LIMIT 1000 + + $$num = $ids->[-1] if @$ids; + $ids; } # only used for mapping external serial numbers (e.g. articles from gmane) |