mirror of
https://github.com/ddworken/hishtory.git
synced 2025-08-15 17:42:41 +02:00
Optimize the apiSubmit function to ensure that it doesn't lead to errors from large insertions
This commit is contained in:
@ -91,3 +91,15 @@ type Feedback struct {
|
||||
Date time.Time `json:"date" gorm:"not null"`
|
||||
Feedback string `json:"feedback"`
|
||||
}
|
||||
|
||||
func Chunks[k any](slice []k, chunkSize int) [][]k {
|
||||
var chunks [][]k
|
||||
for i := 0; i < len(slice); i += chunkSize {
|
||||
end := i + chunkSize
|
||||
if end > len(slice) {
|
||||
end = len(slice)
|
||||
}
|
||||
chunks = append(chunks, slice[i:end])
|
||||
}
|
||||
return chunks
|
||||
}
|
||||
|
Reference in New Issue
Block a user