Skip to content

Instantly share code, notes, and snippets.

@bpaul
Created April 15, 2017 00:02
Show Gist options
  • Save bpaul/103c34ceec2f6107570591d3b1dc53c0 to your computer and use it in GitHub Desktop.
Save bpaul/103c34ceec2f6107570591d3b1dc53c0 to your computer and use it in GitHub Desktop.
def live_release(course_id, do_emails = true, do_push = true)
course = Course.find course_id
emails_sent = pushes_sent = 0
enrollments = course.enrollments.where(is_complete: false).each do |e|
# check the course for new questions and add them to the enrollment
e.last_new_introduced = nil
e.check_questions
# move the questions into todays questions
e.last_new_introduced = nil
e.todays_questions
if do_emails
Resque.enqueue(QuestionsLive, e.id, true)
emails_sent += 1
end
if do_push
Resque.enqueue(PushQuestionsLive, e.id, true)
pushes_sent += 1
end
end
puts "#{emails_sent} emails queued and #{pushes_sent} pushes queued for #{course.title}"
end
@bpaul
Copy link
Author

bpaul commented Apr 17, 2017

Course ID: 13067

@eamonn-webster
Copy link

should we also specify the enterprise?

@bpaul
Copy link
Author

bpaul commented Apr 24, 2017

@eamonn, I agree. I just replicated the production code. Restricting by enterprise is a good idea but probably not an issue in practice

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment