Created
January 24, 2021 16:53
-
-
Save lolaodelola/10232b63216a63c3987d160f6f77c017 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace :affirmation do | |
task :send_text => :environment do |task, args| | |
count = Affirmation.count | |
random_offset = rand(count) | |
affirmation = Affirmation.offset(random_offset).first | |
Developer.confirmed.each do |dev| | |
SendAffirmationJob.new.deliver(dev, affirmation) | |
SentAffirmation.create!(developer_id: dev.id, affirmation_id: affirmation.id, sent_at: DateTime.now) | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment