diff --git a/CHANGELOG.md b/CHANGELOG.md index 7b0fc8d0b..aca587373 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ The format is based on [keep a changelog](http://keepachangelog.com) and this pr ## [Unreleased] ### Fixed - Ensure persisted chat messages listing returns correct order. +- Return correct tournament details in console API leaderboard details endpoint. ## [3.25.0] - 2024-11-25 ### Added diff --git a/server/console_leaderboard.go b/server/console_leaderboard.go index 139a55edc..b7cb83b83 100644 --- a/server/console_leaderboard.go +++ b/server/console_leaderboard.go @@ -90,17 +90,17 @@ func (s *ConsoleServer) GetLeaderboard(ctx context.Context, in *console.Leaderbo var t *api.Tournament var prevReset, nextReset int64 if l.IsTournament() { - results, err := TournamentList(ctx, s.logger, s.db, s.leaderboardCache, l.Category, l.Category, int(l.StartTime), int(l.EndTime), 1, nil) + results, err := TournamentsGet(ctx, s.logger, s.db, s.leaderboardCache, []string{in.Id}) if err != nil { s.logger.Error("Error retrieving tournament.", zap.Error(err)) return nil, status.Error(codes.Internal, "Error retrieving tournament.") } - if len(results.Tournaments) == 0 { + if len(results) == 0 { return nil, status.Error(codes.NotFound, "Leaderboard not found.") } - t = results.Tournaments[0] + t = results[0] } if l.ResetSchedule != nil { diff --git a/server/core_tournament.go b/server/core_tournament.go index 1243141dc..6d209f23e 100644 --- a/server/core_tournament.go +++ b/server/core_tournament.go @@ -169,7 +169,7 @@ ON CONFLICT(owner_id, leaderboard_id, expiry_time) DO NOTHING` return nil }); err != nil { - if err == runtime.ErrTournamentMaxSizeReached { + if errors.Is(err, runtime.ErrTournamentMaxSizeReached) { logger.Info("Failed to join tournament, reached max size allowed.", zap.String("tournament_id", tournamentId), zap.String("owner", ownerID.String()), zap.String("username", username)) return err } @@ -266,7 +266,7 @@ WHERE id = ANY($1::text[])` for rows.Next() { tournament, err := parseTournament(rows, now) if err != nil { - if err == runtime.ErrTournamentNotFound { + if errors.Is(err, runtime.ErrTournamentNotFound) { // This ID mapped to a non-tournament leaderboard, just skip it. continue } @@ -515,7 +515,7 @@ func TournamentRecordWrite(ctx context.Context, logger *zap.Logger, db *sql.DB, var exists int err := db.QueryRowContext(ctx, "SELECT 1 FROM leaderboard_record WHERE leaderboard_id = $1 AND owner_id = $2 AND expiry_time = $3", leaderboard.Id, ownerId, expiryTime).Scan(&exists) if err != nil { - if err == sql.ErrNoRows { + if errors.Is(err, sql.ErrNoRows) { // Tournament required join but no row was found to update. return nil, runtime.ErrTournamentWriteJoinRequired }