You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
educoder/app/jobs/homework_batch_comment_job.rb

21 lines
686 B

5 years ago
# 作业的一键评阅
class HomeworkBatchCommentJob < ApplicationJob
queue_as :default
def perform(comment, hidden_comment, work_ids, homework_id, user_id)
# Do something later
homework = HomeworkCommon.find_by(id: homework_id)
return if homework.blank?
5 years ago
attrs = %i[student_work_id challenge_id user_id comment hidden_comment batch_comment created_at updated_at]
5 years ago
5 years ago
same_attrs = {challenge_id: 0, user_id: user_id, comment: comment, hidden_comment: hidden_comment, batch_comment: 1}
5 years ago
5 years ago
ShixunWorkComment.bulk_insert(*attrs) do |worker|
work_ids.each do |work_id|
worker.add same_attrs.merge(student_work_id: work_id)
5 years ago
end
end
end
end