Fix bugs in pagination and syntax error in artist search endpoint

This commit is contained in:
froge 2025-02-14 12:35:33 +10:00
parent 0990755643
commit 48bf0df6d4
Signed by: froge
GPG key ID: A825E09930271BFA

View file

@ -42,8 +42,8 @@ func paginator() gin.HandlerFunc {
page = 1
}
if pageSize < 10 {
pageSize = 10
if pageSize < 1 {
pageSize = 1
}
// Calculate the correct SQL offset for this page
@ -127,7 +127,7 @@ func (env *Env) getArtistByName(c *gin.Context) {
// NOTE: However unicode is treated case sensitive due to very difficult conversions for some languages/characters
// NOTE: In future better DBs with unicode support such as postgres should be used
var artistProfiles []ArtistProfile
searchString := fmt.Sprintf("%%%s%%"), artistName)
searchString := fmt.Sprintf("%%%s%%", artistName)
dbResult := env.db.Where("name LIKE ?", searchString).Preload("Genres").Offset(pageOffset).Limit(pageSize).Find(&artistProfiles)
if dbResult.Error != nil {
slog.Error("[GOMUSIC] Failed to query local database for artist name", "Name", artistName)