job任务调整

dev_forum
cxt 6 years ago
parent 210c4645e4
commit 1a96c3841d

@ -6,6 +6,7 @@ class ExercisePublishNotifyJob < ApplicationJob
exercise = Exercise.find_by(id: exercise_id)
return if exercise.blank?
user = exercise.user
course = exercise.course
if group_ids.present?
students = course.students.where(course_group_id: group_ids)

@ -5,6 +5,8 @@ class GraduationTaskPublishNotifyJob < ApplicationJob
def perform(graduation_task_id)
task = GraduationTask.find_by(id: graduation_task_id)
return if task.blank?
course = task.course
return if course.blank?
attrs = %i[
user_id trigger_user_id container_id container_type parent_container_id parent_container_type
@ -18,7 +20,7 @@ class GraduationTaskPublishNotifyJob < ApplicationJob
viewed: 0, tiding_type: 'GraduationTask'
}
Tiding.bulk_insert(*attrs) do |worker|
task.course.course_members.pluck(:user_id).uniq.find_each do |user_id|
course.course_members.pluck(:user_id).uniq.find_each do |user_id|
worker.add same_attrs.merge(user_id: user_id)
end
end

@ -19,11 +19,12 @@ class SubmitGraduationWorkNotifyJob < ApplicationJob
next unless User.exists?(id: user_id)
work = task.graduation_works.find_by(user_id: user_id)
next if work.blank?
member = course.students.find_by(user_id: user_id)
next if work.blank? || member.blank?
attrs = same_attrs.merge(trigger_user_id: user_id, container_id: work.id)
course.course_member(user_id).member_teachers.find_each do |teacher|
member.member_teachers.find_each do |teacher|
worker.add attrs.merge(user_id: teacher.user_id)
end
end

@ -19,11 +19,12 @@ class SubmitStudentWorkNotifyJob < ApplicationJob
next unless User.exists?(id: user_id)
work = homework.student_works.find_by(user_id: user_id)
next if work.blank?
member = course.students.find_by(user_id: user_id)
next if work.blank? || member.blank?
attrs = same_attrs.merge(trigger_user_id: user_id, container_id: work.id)
course.course_member(user_id).member_teachers.find_each do |teacher|
member.member_teachers.find_each do |teacher|
worker.add attrs.merge(user_id: teacher.user_id)
end
end

@ -146,11 +146,11 @@ class CourseMember < ApplicationRecord
def member_teachers
teacher_groups = course.teacher_course_groups
if teacher_groups.count > 0
member_ids = teacher_groups.where(course_group_id: self.try(:course_group_id)).pluck(:course_member_id)
member_ids = teacher_groups.where(course_group_id: self.try(:course_group_id)).pluck(:course_member_id).compact
none_group_teachers = teacher_groups.pluck(:course_member_id).size > 0 ? teacher_groups.pluck(:course_member_id).join(',') : -1
teachers = course.teachers.where("members.id not in (#{none_group_teachers}) or
members.id in (#{member_ids.size > 0 ? member_ids.join(',') : -1})")
none_group_teachers = teacher_groups.pluck(:course_member_id).size > 0 ? teacher_groups.pluck(:course_member_id).compact.join(',') : -1
teachers = course.teachers.where("course_members.id not in (#{none_group_teachers}) or
course_members.id in (#{member_ids.size > 0 ? member_ids.join(',') : -1})")
else
teachers = course.teachers
end

Loading…
Cancel
Save