diff --git a/internal/autoassigner/autoassigner.go b/internal/autoassigner/autoassigner.go index 37114cea..427a234a 100644 --- a/internal/autoassigner/autoassigner.go +++ b/internal/autoassigner/autoassigner.go @@ -5,6 +5,7 @@ import ( "context" "errors" "fmt" + "math/rand" "strconv" "sync" "time" @@ -145,6 +146,12 @@ func (e *Engine) populateTeamBalancer() error { continue } + // Shuffle users to prevent ordering bias, as every app restart will pick the same first user. + r := rand.New(rand.NewSource(time.Now().UnixNano())) + r.Shuffle(len(users), func(i, j int) { + users[i], users[j] = users[j], users[i] + }) + for _, user := range users { // Team does not have a balancer pool, create one. if _, ok := e.roundRobinBalancer[team.ID]; !ok {