试卷截止时的异步任务调整

schedule_job
cxt 5 years ago
parent fc0058fb52
commit afb856ee26

@ -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

@ -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?

Loading…
Cancel
Save