From 0d254b0da4c2701e3efc0a8b5184e4e8e0b6434a Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Wed, 3 Jul 2019 16:16:24 +0800 Subject: [PATCH] score fix --- app/controllers/homework_commons_controller.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/homework_commons_controller.rb b/app/controllers/homework_commons_controller.rb index 4cd9209f3..57ae1023b 100644 --- a/app/controllers/homework_commons_controller.rb +++ b/app/controllers/homework_commons_controller.rb @@ -250,7 +250,7 @@ class HomeworkCommonsController < ApplicationController challenge_settings = @homework.homework_challenge_settings myshixuns.find_each(batch_size: 100) do |myshixun| work = student_works.select{|work| work.user_id == myshixun.user_id}.first - if work && myshixun && (work.update_time.nil? || work.update_time < myshixun.updated_at) + if work && myshixun && (work.update_time.nil? || work.update_time < myshixun.games.pluck(:updated_at).max) games = myshixun.games.where(challenge_id: challenge_settings.pluck(:challenge_id)) HomeworksService.new.update_myshixun_work_score work, myshixun, games, @homework, challenge_settings end @@ -271,7 +271,7 @@ class HomeworkCommonsController < ApplicationController myshixun = Myshixun.find_by(shixun_id: params[:shixun_id], user_id: current_user.id) ActiveRecord::Base.transaction do begin - if work && myshixun && (work.update_time.nil? || work.update_time < myshixun.updated_at) + if work && myshixun && (work.update_time.nil? || work.update_time < myshixun.games.pluck(:updated_at).max) challenge_settings = @homework.homework_challenge_settings games = myshixun.games.where(challenge_id: challenge_settings.pluck(:challenge_id)) HomeworksService.new.update_myshixun_work_score work, myshixun, games, @homework, challenge_settings