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.
|
|
|
# 任务发布 消息通知
|
|
|
|
class GraduationTaskPublishNotifyJob < ApplicationJob
|
|
|
|
queue_as :notify
|
|
|
|
|
|
|
|
def perform(graduation_task_id)
|
|
|
|
task = GraduationTask.find_by(id: graduation_task_id)
|
|
|
|
return if task.blank?
|
|
|
|
|
|
|
|
attrs = %i[
|
|
|
|
user_id trigger_user_id container_id container_type parent_container_id parent_container_type
|
|
|
|
belong_container_id belong_container_type viewed tiding_type created_at updated_at
|
|
|
|
]
|
|
|
|
|
|
|
|
same_attrs = {
|
|
|
|
trigger_user_id: task.user_id, container_id: task.id, container_type: 'GraduationTask',
|
|
|
|
parent_container_id: task.id, parent_container_type: 'TaskPublish',
|
|
|
|
belong_container_id: task.course_id, belong_container_type: 'Course',
|
|
|
|
viewed: 0, tiding_type: 'GraduationTask'
|
|
|
|
}
|
|
|
|
Tiding.bulk_insert(*attrs) do |worker|
|
|
|
|
task.course.course_members.pluck(:user_id).uniq.find_each do |user_id|
|
|
|
|
worker.add same_attrs.merge(user_id: user_id)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|