-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Extract configuration to a separate Rake task (#536)
- Loading branch information
1 parent
c82e27a
commit df005dc
Showing
1 changed file
with
9 additions
and
9 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,28 +1,28 @@ | ||
namespace :feeder do | ||
desc 'Pull one specific feed: "rake feeder:pull[feed_name]"' | ||
task pull: :environment do |_task, args| | ||
desc "Update feeds configuration" | ||
task configuration: :environment do | ||
FeedsConfiguration.sync | ||
end | ||
|
||
desc "Pull one specific feed: rake feeder:pull[feed_name]" | ||
task pull: :configuration do |_task, args| | ||
# TODO: Move to a service | ||
feed_name = args.extras[0] | ||
raise "feed name is required" unless feed_name | ||
FeedsConfiguration.sync | ||
feed = Feed.enabled.find_by(name: feed_name) | ||
raise "specified feed does not exist or enabled" unless feed | ||
ProcessFeed.new(feed).process | ||
end | ||
|
||
desc "Pull all feeds" | ||
task pull_all: :environment do | ||
FeedsConfiguration.sync | ||
task pull_all: :configuration do | ||
Feed.enabled.each { |feed| ProcessFeed.new(feed).process } | ||
end | ||
|
||
desc "Pull stale feeds" | ||
task pull_stale: :environment do | ||
task pull_stale: :configuration do | ||
# TODO: Move to a service | ||
FeedsConfiguration.sync | ||
feeds = Feed.enabled.stale | ||
feed_names = feeds.pluck(:name).join(", ") | ||
Rails.logger.info("---> updating #{feeds.count} feed(s): #{feed_names}") | ||
feeds.each { |feed| ProcessFeed.new(feed).process } | ||
end | ||
end |