diff options
author | Eric Wong <e@80x24.org> | 2020-11-27 09:52:45 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2020-11-28 04:53:14 +0000 |
commit | ac43c3b17f452b02edf1cce3632a433e998de5ca (patch) | |
tree | ddb44342dd894fdfe757c816cb24615247af34bb /lib/PublicInbox/Msgmap.pm | |
parent | fb7d0067dc55fa8336dab96c07807fc7b28a1b20 (diff) | |
download | public-inbox-ac43c3b17f452b02edf1cce3632a433e998de5ca.tar.gz |
This simplifies callers and allows empty newsgroups to be represented (the WWW UI may be insufficient there, too).
Diffstat (limited to 'lib/PublicInbox/Msgmap.pm')
-rw-r--r-- | lib/PublicInbox/Msgmap.pm | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/lib/PublicInbox/Msgmap.pm b/lib/PublicInbox/Msgmap.pm index f15875e3..a8c874af 100644 --- a/lib/PublicInbox/Msgmap.pm +++ b/lib/PublicInbox/Msgmap.pm @@ -36,8 +36,7 @@ sub new_file { create_tables($dbh); $self->created_at(time) unless $self->created_at; - my $max = $self->max // 0; - $self->num_highwater($max); + $self->num_highwater(max($self)); $dbh->commit; } $self; @@ -144,7 +143,7 @@ sub max { my $sth = $_[0]->{dbh}->prepare_cached('SELECT MAX(num) FROM msgmap', undef, 1); $sth->execute; - $sth->fetchrow_array; + $sth->fetchrow_array // 0; } sub minmax { @@ -153,7 +152,7 @@ sub minmax { my $sth = $_[0]->{dbh}->prepare_cached('SELECT MIN(num) FROM msgmap', undef, 1); $sth->execute; - ($sth->fetchrow_array, max($_[0])); + ($sth->fetchrow_array // 0, max($_[0])); } sub mid_delete { |