mirror of
https://github.com/navidrome/navidrome.git
synced 2026-08-31 07:30:32 +00:00
Replace custom chunking logic with a utils.BreakUpStringSlice call
This commit is contained in:
parent
0a7a06bdc9
commit
7cdbf3c217
@ -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…
x
Reference in New Issue
Block a user