Add event management features to API, including event cancellation, deletion, registration closure, and workflow balance generation. Introduce new roster management endpoints and enhance participant handling with avoided player preferences. Update database schema and service logic to support these changes.
Some checks failed
CI / backend (push) Has been cancelled
CI / frontend (push) Has been cancelled
CI / compose (push) Has been cancelled

This commit is contained in:
2026-07-19 02:10:02 +03:00
parent 59c0bdb345
commit 4b889fb8a0
30 changed files with 2766 additions and 149 deletions

View File

@@ -64,6 +64,7 @@ type Player struct {
Ratings Ratings `json:"ratings"`
PreferredRoles []Role `json:"preferredRoles"`
PreferredPlayerIDs []string `json:"preferredPlayerIds"`
AvoidedPlayerIDs []string `json:"avoidedPlayerIds"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
}
@@ -72,6 +73,9 @@ func (p Player) ValidatePreferences() error {
if len(p.PreferredPlayerIDs) > 3 {
return fmt.Errorf("%w: at most three preferred teammates are allowed", ErrInvalid)
}
if len(p.AvoidedPlayerIDs) > 3 {
return fmt.Errorf("%w: at most three avoided teammates are allowed", ErrInvalid)
}
seenRoles := map[Role]bool{}
for _, role := range p.PreferredRoles {
if (role != Tank && role != Damage && role != Support) || seenRoles[role] {
@@ -86,19 +90,31 @@ func (p Player) ValidatePreferences() error {
}
seenPlayers[playerID] = true
}
seenAvoids := map[string]bool{}
for _, playerID := range p.AvoidedPlayerIDs {
if playerID == "" || playerID == p.ID || seenAvoids[playerID] || seenPlayers[playerID] {
return fmt.Errorf("%w: invalid avoided teammates", ErrInvalid)
}
seenAvoids[playerID] = true
}
return nil
}
type Event struct {
ID string `json:"id"`
Name string `json:"name"`
Description string `json:"description"`
StartsAt time.Time `json:"startsAt"`
EndsAt time.Time `json:"endsAt"`
RegistrationDeadline time.Time `json:"registrationDeadline"`
CreatedBy string `json:"createdBy"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
ID string `json:"id"`
Name string `json:"name"`
Description string `json:"description"`
StartsAt time.Time `json:"startsAt"`
EndsAt time.Time `json:"endsAt"`
RegistrationDeadline time.Time `json:"registrationDeadline"`
CreatedBy string `json:"createdBy"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
State EventState `json:"state"`
Version int `json:"version"`
RulesetID string `json:"rulesetId"`
ActiveSeriesID string `json:"activeSeriesId"`
TournamentID string `json:"tournamentId"`
}
func (e Event) Validate() error {
@@ -364,14 +380,27 @@ type MapResult struct {
}
type Series struct {
ID string `json:"id"`
TournamentID string `json:"tournamentId"`
TeamAID string `json:"teamAId"`
TeamBID string `json:"teamBId"`
WinnerTeamID string `json:"winnerTeamId"`
BestOf int `json:"bestOf"`
Results []MapResult `json:"results"`
Version int `json:"version"`
ID string `json:"id"`
EventID string `json:"eventId"`
TournamentID string `json:"tournamentId"`
TeamAID string `json:"teamAId"`
TeamBID string `json:"teamBId"`
WinnerTeamID string `json:"winnerTeamId"`
BestOf int `json:"bestOf"`
RulesetID string `json:"rulesetId"`
Phase SeriesPhase `json:"phase"`
CoinToss *CoinToss `json:"coinToss,omitempty"`
MapDraft *MapDraft `json:"mapDraft,omitempty"`
HeroDraft *HeroDraft `json:"heroDraft,omitempty"`
CurrentMap string `json:"currentMap"`
PlayedMaps []string `json:"playedMaps"`
NextMapPickerID string `json:"nextMapPickerId"`
AvailableMaps []string `json:"availableMaps"`
Maps []SeriesMap `json:"maps"`
SeriesBans map[string][]string `json:"seriesBans"`
Audit []SeriesAction `json:"audit"`
Results []MapResult `json:"results"`
Version int `json:"version"`
}
func (s *Series) RecordResult(result MapResult) error {