Replace custom chunking logic with a utils.BreakUpStringSlice call
This commit is contained in:
parent
9a3e75be00
commit
22145e070f
1 changed files with 2 additions and 10 deletions
|
|
@ -9,6 +9,7 @@ import (
|
||||||
"github.com/astaxie/beego/orm"
|
"github.com/astaxie/beego/orm"
|
||||||
"github.com/deluan/navidrome/log"
|
"github.com/deluan/navidrome/log"
|
||||||
"github.com/deluan/navidrome/model"
|
"github.com/deluan/navidrome/model"
|
||||||
|
"github.com/deluan/navidrome/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
type playQueueRepository struct {
|
type playQueueRepository struct {
|
||||||
|
|
@ -112,16 +113,7 @@ func (r *playQueueRepository) loadTracks(tracks model.MediaFiles) model.MediaFil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Break the list in chunks, up to 50 items, to avoid hitting SQLITE_MAX_FUNCTION_ARG limit
|
// Break the list in chunks, up to 50 items, to avoid hitting SQLITE_MAX_FUNCTION_ARG limit
|
||||||
const chunkSize = 50
|
chunks := utils.BreakUpStringSlice(ids, 50)
|
||||||
var chunks [][]string
|
|
||||||
for i := 0; i < len(ids); i += chunkSize {
|
|
||||||
end := i + chunkSize
|
|
||||||
if end > len(ids) {
|
|
||||||
end = len(ids)
|
|
||||||
}
|
|
||||||
|
|
||||||
chunks = append(chunks, ids[i:end])
|
|
||||||
}
|
|
||||||
|
|
||||||
// Query each chunk of media_file ids and store results in a map
|
// Query each chunk of media_file ids and store results in a map
|
||||||
mfRepo := NewMediaFileRepository(r.ctx, r.ormer)
|
mfRepo := NewMediaFileRepository(r.ctx, r.ormer)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue