From b6095496595535d8344b40bd54a946b82e0a5f67 Mon Sep 17 00:00:00 2001 From: Malaber Date: Fri, 1 Jul 2022 20:19:57 +0200 Subject: [PATCH] Add logging if updating group scores fails --- app/controllers/matches_controller.rb | 13 +++++++++++-- config/environment.rb | 3 +++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/app/controllers/matches_controller.rb b/app/controllers/matches_controller.rb index ccbfe4b..cf24488 100644 --- a/app/controllers/matches_controller.rb +++ b/app/controllers/matches_controller.rb @@ -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? diff --git a/config/environment.rb b/config/environment.rb index d5abe55..d8d3793 100644 --- a/config/environment.rb +++ b/config/environment.rb @@ -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")