Clean up get_last_page()

This commit is contained in:
swagg boi 2021-12-25 01:46:39 -05:00
parent 89712d81a8
commit 328e1f4d4d

View file

@ -50,15 +50,11 @@ sub max_posts($self, $value = undef) {
} }
sub get_last_page($self) { sub get_last_page($self) {
my $post_count = get_post_count($self); my $post_count = $self->get_post_count();
my $last_page = sprintf('%d', $post_count / $self->{'max_posts'});
# Add a page if we have "remainder" posts # Add a page if we have "remainder" posts
if ($post_count % $self->{'max_posts'}) { return $post_count % $self->{'max_posts'} ? ++$last_page : $last_page;
sprintf('%d', $post_count / $self->{'max_posts'}) + 1
}
else {
sprintf('%d', $post_count / $self->{'max_posts'})
}
} }
sub get_post_count($self) { sub get_post_count($self) {