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/course_video_uploaded_job.rb

26 lines
805 B

class CourseVideoUploadedJob < ApplicationJob
queue_as :notify
def perform(video_id)
video = Video.select("id, user_id").find_by(id: video_id)
course_ids = video&.course_videos&.pluck(:course_id)
return unless course_ids.present?
course_members = CourseMember.where(course_id: course_ids, role: 'STUDENT').select("id, user_id, course_id")
Tiding.bulk_insert do |worker|
course_members.find_each do |m|
worker.add(
user_id: m.user_id,
tiding_type: 'PublishCourseVideo',
trigger_user_id: video.user_id,
container_id: video.id,
container_type: 'Video',
belong_container_type: 'Course',
belong_container_id: m.course_id)
end
end
end
end