From afb856ee2688c9cb3af0c3e2583ab928545fe701 Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Mon, 23 Mar 2020 16:12:31 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AF=95=E5=8D=B7=E6=88=AA=E6=AD=A2=E6=97=B6?= =?UTF-8?q?=E7=9A=84=E5=BC=82=E6=AD=A5=E4=BB=BB=E5=8A=A1=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/exercises_controller.rb | 4 ++-- app/jobs/end_exercise_calculate_job.rb | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/app/controllers/exercises_controller.rb b/app/controllers/exercises_controller.rb index d99c59c85..e20a8bd28 100644 --- a/app/controllers/exercises_controller.rb +++ b/app/controllers/exercises_controller.rb @@ -816,7 +816,7 @@ class ExercisesController < ApplicationController ex_user_ids = exercise_users.pluck(:id) - EndExerciseCalculateJob.perform_later(ex_user_ids, exercise, Time.now.to_s, true, 4) + EndExerciseCalculateJob.perform_later(ex_user_ids, exercise.id, Time.now.to_s, true, 4) # exercise_users.each do |user| # if user.commit_status == 0 && user.start_at.present? # objective_score = calculate_student_score(exercise,user.user)[:total_score] @@ -1194,7 +1194,7 @@ class ExercisesController < ApplicationController start_time = Time.current - @exercise.time * 60 ex_user_ids = @exercise_users_list.where("start_at <= '#{Time.at(start_time)}' and commit_status = 0").pluck(:id) if ex_user_ids.size > 0 - EndExerciseCalculateJob.perform_later(ex_user_ids, @exercise, Time.now.to_s, false, 2) + EndExerciseCalculateJob.perform_later(ex_user_ids, @exercise.id, Time.now.to_s, false, 2) end end diff --git a/app/jobs/end_exercise_calculate_job.rb b/app/jobs/end_exercise_calculate_job.rb index 28f1f6901..3354be2d5 100644 --- a/app/jobs/end_exercise_calculate_job.rb +++ b/app/jobs/end_exercise_calculate_job.rb @@ -5,7 +5,9 @@ class EndExerciseCalculateJob < ApplicationJob queue_as :default - def perform(ex_user_ids,exercise,end_time,work_time,commit_method) + def perform(ex_user_ids,exercise_id,end_time,work_time,commit_method) + exercise = Exercise.find_by(id: exercise_id) + return if exercise.blank? exercise_users = ExerciseUser.where(id: ex_user_ids) exercise_users.each do |user| if user.commit_status == 0 && user.start_at.present?