Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions engine/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,8 @@ type MiscConfig struct {

StartPaused bool

TeamCount int // Auto-generate teams (team01, team02, ...) if > 0

// Round settings
Delay int
Jitter int
Expand Down
19 changes: 19 additions & 0 deletions engine/db/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,25 @@ func Connect(connectURL string) {
}

func AddTeams(conf *config.ConfigSettings) error {
// Auto-generate teams if TeamCount is specified
if conf.MiscSettings.TeamCount > 0 {
for i := 1; i <= conf.MiscSettings.TeamCount; i++ {
teamName := fmt.Sprintf("team%02d", i)
t := TeamSchema{Name: teamName}
result := db.Where(&t).First(&t)
if result.Error != nil {
if errors.Is(result.Error, gorm.ErrRecordNotFound) {
if _, err := CreateTeam(t); err != nil {
return err
}
} else {
return result.Error
}
}
}
}

// Also add explicitly defined teams
for _, team := range conf.Team {
t := TeamSchema{Name: team.Name}
result := db.Where(&t).First(&t)
Expand Down