Skip to content

Commit

Permalink
Implement a rake task for each frequency
Browse files Browse the repository at this point in the history
  • Loading branch information
yogodoshi committed Oct 17, 2017
1 parent 2250d71 commit 2379294
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions lib/tasks/tweet.rake
Original file line number Diff line number Diff line change
@@ -1,6 +1,22 @@
desc 'Tweet to the company from each User'
task tweet_to_the_company: :environment do
User.where.not(frequency: 'off').find_each do |user|
desc 'Tweet from the users that choose to do it weekly'
task tweet_weekly_to_the_company: :environment do
if Time.current.wday == 1 # Check if its monday as heroku scheduler doesnt have "weekly frequency"
User.low.find_each do |user|
TwitterService.new(user).tweet_to_the_company
end
end
end

desc 'Tweet from the users that choose to do it daily'
task tweet_daily_to_the_company: :environment do
User.medium.find_each do |user|
TwitterService.new(user).tweet_to_the_company
end
end

desc 'Tweet from the users that choose to do it hourly'
task tweet_hourly_to_the_company: :environment do
User.high.find_each do |user|
TwitterService.new(user).tweet_to_the_company
end
end

0 comments on commit 2379294

Please sign in to comment.