Update groups points at start and end of a match

This commit is contained in:
Daniel Schädler 2022-06-25 18:20:59 +02:00
parent e448f9ccc3
commit bbb8e209df
Signed by: Malaber
GPG Key ID: 4BB175A9617E4B11
1 changed files with 4 additions and 0 deletions

View File

@ -49,6 +49,9 @@ class MatchesController < ApplicationController
Match.transaction do
if @match.update(match_params)
handle_match_end if new_state == 'finished'
if @match.group_match? and new_state == "in_progress"
UpdateGroupsGroupScoresAndSave.call(group: @match.group)
end
render json: @match
else
@ -61,6 +64,7 @@ class MatchesController < ApplicationController
private
def handle_match_end
UpdateGroupsGroupScoresAndSave.call(group: @match.group) if @match.group_match?
return if @match.group_match?
if @match.winner.nil?