Files
rootandClaude Opus 4.7 79ac89b458 Initial commit
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-11-07 10:47:18 +08:00

34 lines
703 B
Go

package srv_aicomment
import (
"math/rand"
)
const (
commentsPerGenerationTask = 8
aiCommentPlayletTotal = 3
)
func selectAIComments(comments []Comment, count int) []Comment {
available := make([]Comment, 0, len(comments))
for _, comment := range comments {
if comment.Text != "" {
available = append(available, comment)
}
}
if count <= 0 || len(available) <= count {
return available
}
rand.Shuffle(len(available), func(i, j int) {
available[i], available[j] = available[j], available[i]
})
return available[:count]
}
func randomIntInclusive(minValue, maxValue int) int {
if maxValue <= minValue {
return minValue
}
return minValue + rand.Intn(maxValue-minValue+1)
}