-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement a rake task for each frequency
- Loading branch information
Showing
1 changed file
with
19 additions
and
3 deletions.
There are no files selected for viewing
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
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 |