# 作业的一键评阅 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? attrs = %i[student_work_id challenge_id user_id comment hidden_comment batch_comment created_at updated_at] same_attrs = {challenge_id: 0, user_id: user_id, comment: comment, hidden_comment: hidden_comment, batch_comment: 1} ShixunWorkComment.bulk_insert(*attrs) do |worker| work_ids.each do |work_id| worker.add same_attrs.merge(student_work_id: work_id) end end end end