From 863ea1c47e1946e494813a3053aee6aa41d92b1d Mon Sep 17 00:00:00 2001 From: mytja Date: Sun, 21 Jan 2024 19:20:14 +0100 Subject: [PATCH] turnir --- backend/internal/tournament/goroutine.go | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/backend/internal/tournament/goroutine.go b/backend/internal/tournament/goroutine.go index 7a1c9c8..e99333a 100644 --- a/backend/internal/tournament/goroutine.go +++ b/backend/internal/tournament/goroutine.go @@ -245,8 +245,18 @@ func (s *tournamentImpl) CalculateRating() { } func (s *tournamentImpl) EndTournament() { - s.CalculateRating() - s.logger.Debugw("rating calculated. now awaiting game ends.") + 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") time.Sleep(1 * time.Second) for i := range s.games { s.wsServer.EndGame(i)