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

@ -28,6 +28,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"
"golang.org/x/oauth2/spotify"
)
@ -183,10 +184,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
}