refactor(server): replace RangeByChunks with Go 1.23 iterators (#3292)

* refactor(server): replace RangeByChunks with Go 1.23 iterators

* chore: fix comments re: SQLITE_MAX_VARIABLE_NUMBER

* test: improve playqueue test

* refactor(server): don't create a new iterator when it is not required
This commit is contained in:
Deluan Quintão
2024-09-22 11:47:10 -04:00
committed by GitHub
parent 3910e77a7a
commit 669c8f4c49
9 changed files with 79 additions and 99 deletions
+1 -4
View File
@@ -5,7 +5,6 @@ import (
"fmt"
"maps"
"path/filepath"
"slices"
"strings"
"time"
@@ -72,9 +71,7 @@ func (r *refresher) flushMap(ctx context.Context, m map[string]struct{}, entity
return nil
}
ids := slices.Collect(maps.Keys(m))
chunks := slice.BreakUp(ids, 100)
for _, chunk := range chunks {
for chunk := range slice.CollectChunks(maps.Keys(m), 200) {
err := refresh(ctx, chunk...)
if err != nil {
log.Error(ctx, fmt.Sprintf("Error writing %ss to the DB", entity), err)