Change playoff transition relevant attributes of tournament on update
They are only updated when playoff_teams_amount changed alone
This commit is contained in:
parent
608e776276
commit
701fc0f357
|
|
@ -64,10 +64,20 @@ class TournamentsController < ApplicationController
|
|||
|
||||
# PATCH/PUT /tournaments/1
|
||||
def update
|
||||
Tournament.transaction do
|
||||
if only_playoff_teams_amount_changed
|
||||
@tournament.instant_finalists_amount, @tournament.intermediate_round_participants_amount =
|
||||
TournamentService.calculate_default_amount_of_teams_advancing(
|
||||
params['playoff_teams_amount'].to_i,
|
||||
@tournament.stages.find_by(level: -1).groups.size
|
||||
)
|
||||
end
|
||||
if @tournament.update(tournament_params)
|
||||
render json: @tournament
|
||||
else
|
||||
render json: @tournament.errors, status: :unprocessable_entity
|
||||
raise ActiveRecord::Rollback
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue