Refactor series handling in backend to include player context in Toss, Ban, Pick, and Record actions. Update service methods to accept player parameters, enhancing authorization checks and ensuring proper team actions. Modify integration tests to reflect new method signatures and improve tournament hydration logic in the store. Enhance frontend components to support new series features and improve user experience with live match navigation.
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 03:22:32 +03:00
parent 4b8218ec14
commit 5d3e66d2f1
16 changed files with 449 additions and 62 deletions

View File

@@ -612,6 +612,9 @@ func (s *Store) GetTournament(ctx context.Context, id string) (domain.Tournament
if err == nil {
err = json.Unmarshal(body, &out)
}
if err == nil {
err = s.hydrateTournament(ctx, &out)
}
return out, mapError(err)
}
@@ -622,9 +625,43 @@ func (s *Store) GetTournamentByEvent(ctx context.Context, eventID string) (domai
if err == nil {
err = json.Unmarshal(body, &out)
}
if err == nil {
err = s.hydrateTournament(ctx, &out)
}
return out, mapError(err)
}
func (s *Store) hydrateTournament(ctx context.Context, tournament *domain.Tournament) error {
rows, err := s.pool.Query(ctx, `SELECT body FROM series WHERE tournament_id=$1`, tournament.ID)
if err != nil {
return err
}
defer rows.Close()
live := make(map[string]domain.Series)
for rows.Next() {
var body []byte
var series domain.Series
if err := rows.Scan(&body); err != nil {
return err
}
if err := json.Unmarshal(body, &series); err != nil {
return err
}
live[series.ID] = series
}
if err := rows.Err(); err != nil {
return err
}
for round := range tournament.Rounds {
for match := range tournament.Rounds[round] {
if series, ok := live[tournament.Rounds[round][match].ID]; ok {
tournament.Rounds[round][match] = series
}
}
}
return nil
}
func (s *Store) SaveDraft(ctx context.Context, id, kind string, value any, expectedVersion int) error {
body, _ := json.Marshal(value)
if expectedVersion < 0 {