Skip to content

Commit

Permalink
fix(api): pager needs to give one less page
Browse files Browse the repository at this point in the history
  • Loading branch information
BaptTF committed May 4, 2024
1 parent 4f2e4eb commit c18faa1
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion backend/autogen/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package autogen
import (
"math"
"time"
"github.com/sirupsen/logrus"
)

func OptionalString(s string) *string {
Expand Down Expand Up @@ -101,7 +102,7 @@ func Pager(page *uint64, limit *uint64, count *uint64) (dbPage uint64, pageOut u
// We calculate the max page (0 if count is nil)
if count != nil {
maxPageFloat := float64(*count) / float64(limitOut)
maxPage = uint64(math.Floor(maxPageFloat))
maxPage = uint64(math.Ceil(maxPageFloat) - 1)
}

if pageOut > maxPage+1 {
Expand Down

0 comments on commit c18faa1

Please sign in to comment.