mirror of
https://github.com/stashapp/stash.git
synced 2025-12-07 00:43:12 +01:00
* Add findFile and findFiles * Add parent folder and zip file fields to file graphql types * Add parent_folder, zip_file fields to Folder graphql type * Add format to ImageFile type * Add format filter fields to image/video file filters
20 lines
410 B
Go
20 lines
410 B
Go
package sqlite
|
|
|
|
const defaultBatchSize = 1000
|
|
|
|
// batchExec executes the provided function in batches of the provided size.
|
|
func batchExec[T any](ids []T, batchSize int, fn func(batch []T) error) error {
|
|
for i := 0; i < len(ids); i += batchSize {
|
|
end := i + batchSize
|
|
if end > len(ids) {
|
|
end = len(ids)
|
|
}
|
|
|
|
batch := ids[i:end]
|
|
if err := fn(batch); err != nil {
|
|
return err
|
|
}
|
|
}
|
|
|
|
return nil
|
|
}
|