Skip to content

Commit

Permalink
fixić
Browse files Browse the repository at this point in the history
  • Loading branch information
mytja committed Jan 21, 2024
1 parent ed6d870 commit 11ba5c4
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions backend/internal/tournament/goroutine.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 11ba5c4

Please sign in to comment.