Add logging if updating group scores fails

This commit is contained in:
Daniel Schädler 2022-07-01 20:19:57 +02:00
parent a67ef86dca
commit b609549659
Signed by: Malaber
GPG Key ID: 4BB175A9617E4B11
2 changed files with 14 additions and 2 deletions

View File

@ -52,7 +52,10 @@ class MatchesController < ApplicationController
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)
group = @match.group
if UpdateGroupsGroupScoresAndSave.call(group: group).success?
Rails.logger.warn "Updating groups group score failed for #{group}"
end
end
render json: @match
@ -66,7 +69,13 @@ class MatchesController < ApplicationController
private
def handle_match_end
UpdateGroupsGroupScoresAndSave.call(group: @match.group) if @match.group_match?
if @match.group_match?
group = @match.group
unless UpdateGroupsGroupScoresAndSave.call(group: group).success?
Rails.logger.warn "Updating groups group score failed for #{group}"
end
end
return if @match.group_match?
if @match.winner.nil?

View File

@ -5,3 +5,6 @@ require_relative 'application'
# Initialize the Rails application.
Rails.application.initialize!
Rails.logger = Logger.new(STDOUT)
config.logger = ActiveSupport::Logger.new("log/#{Rails.env}.log")