Added util.Min and util.Max helpers

This commit is contained in:
Philipp Wolfer 2023-12-11 22:48:08 +01:00
parent be1cfdac9e
commit c4da3a40cc
No known key found for this signature in database
GPG key ID: 8FDF744D4919943B
4 changed files with 73 additions and 12 deletions

View file

@ -26,6 +26,7 @@ import (
"go.uploadedlobster.com/scotty/internal/config"
"go.uploadedlobster.com/scotty/internal/i18n"
"go.uploadedlobster.com/scotty/internal/models"
"go.uploadedlobster.com/scotty/internal/util"
"golang.org/x/oauth2"
)
@ -105,10 +106,7 @@ out:
// and continue.
if offset >= result.Total {
p.Total = int64(result.Total)
offset = result.Total - perPage
if offset < 0 {
offset = 0
}
offset = util.Max(result.Total-perPage, 0)
continue
}
@ -177,10 +175,7 @@ out:
if offset >= result.Total {
p.Total = int64(result.Total)
totalCount = result.Total
offset = result.Total - perPage
if offset < 0 {
offset = 0
}
offset = util.Max(result.Total-perPage, 0)
continue
}