diff --git a/backend/internal/tournament/goroutine.go b/backend/internal/tournament/goroutine.go index 1791f4f..88ab42d 100644 --- a/backend/internal/tournament/goroutine.go +++ b/backend/internal/tournament/goroutine.go @@ -186,6 +186,16 @@ func (s *tournamentImpl) CalculateRating() { } } + tournament, err := s.db.GetTournament(s.tournamentId) + if err != nil { + s.logger.Errorw("tournament fetching failed", "err", err) + return + } + + if !tournament.Rated { + return + } + if len(ratingCalc) == 0 { return } @@ -245,18 +255,8 @@ func (s *tournamentImpl) CalculateRating() { } func (s *tournamentImpl) EndTournament() { - tournament, err := s.db.GetTournament(s.tournamentId) - if err != nil { - s.logger.Errorw("tournament fetching failed", "err", err) - return - } - - if tournament.Rated { - s.CalculateRating() - s.logger.Debugw("rating calculated") - } - - s.logger.Debugw("awaiting game ends") + s.CalculateRating() + s.logger.Debugw("rating calculated. awaiting game ends") time.Sleep(1 * time.Second) for i := range s.games { s.wsServer.EndGame(i)