From 433a9f75d7a5de0e6da2cf7c27e8a34b807ec9c5 Mon Sep 17 00:00:00 2001 From: Just Me Date: Sun, 1 Oct 2023 01:44:54 +0300 Subject: [PATCH] Use result multiplier in the sum calculation --- app/channels/api_channel.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/channels/api_channel.rb b/app/channels/api_channel.rb index 1ef6b8b0..e4633ec3 100644 --- a/app/channels/api_channel.rb +++ b/app/channels/api_channel.rb @@ -155,11 +155,13 @@ def finish data users_without_result = [] begin + result_multiplier = Rational(task.result_multiplier) + ActiveRecord::Base.transaction do task.contest.users.find_each do |user| user_result = CriterionUserResult.where user:, criterion: task.criterions users_without_result << user.judge_secret unless user_result.count == task.criterions_count - score = user_result.sum :value + score = user_result.sum(:value) * result_multiplier Result.create_or_find_by!(user:, task:).update!(score:) end