Class: Pluto::Refresher
- Inherits:
-
Object
- Object
- Pluto::Refresher
- Includes:
- LogUtils::Logging, Models
- Defined in:
- lib/pluto/update/refresher.rb
Instance Method Summary collapse
- #debug=(value) ⇒ Object
- #debug? ⇒ Boolean
-
#initialize ⇒ Refresher
constructor
A new instance of Refresher.
-
#update_feeds(opts = {}) ⇒ Object
update all feeds.
- #update_feeds_for(site_key, opts = {}) ⇒ Object
-
#update_sites(opts = {}) ⇒ Object
update all site configs.
Constructor Details
Instance Method Details
#debug=(value) ⇒ Object
16 |
# File 'lib/pluto/update/refresher.rb', line 16 def debug=(value) @debug = value; end |
#debug? ⇒ Boolean
17 |
# File 'lib/pluto/update/refresher.rb', line 17 def debug?() @debug || false; end |
#update_feeds(opts = {}) ⇒ Object
update all feeds
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/pluto/update/refresher.rb', line 38 def update_feeds( opts={} ) # update all feeds if debug? ## turn on logging for sql too ActiveRecord::Base.logger = Logger.new( STDOUT ) @worker.debug = true # also pass along worker debug flag if set end # -- log update activity Activity.create!( text: "update feeds (#{Feed.count})" ) #### - hack - use order(:id) instead of .all - avoids rails/activerecord 4 warnings Feed.order(:id).each do |feed| update_feed_worker( feed ) end end |
#update_feeds_for(site_key, opts = {}) ⇒ Object
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/pluto/update/refresher.rb', line 56 def update_feeds_for( site_key, opts={} ) if debug? ## turn on logging for sql too ActiveRecord::Base.logger = Logger.new( STDOUT ) @worker.debug = true # also pass along worker debug flag if set end # -- log update activity Activity.create!( text: "update feeds >#{site_key}<" ) site = Site.find_by_key!( site_key ) site.feeds.each do |feed| update_feed_worker( feed ) end end |
#update_sites(opts = {}) ⇒ Object
update all site configs
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/pluto/update/refresher.rb', line 20 def update_sites( opts={} ) # update all site configs if debug? ## turn on logging for sql too ActiveRecord::Base.logger = Logger.new( STDOUT ) @worker.debug = true # also pass along worker debug flag if set end # -- log update activity Activity.create!( text: "update sites (#{Site.count})" ) #### - hack - use order(:id) instead of .all - avoids rails/activerecord 4 warnings Site.order(:id).each do |site| update_site_worker( site ) if site.url.present? # note: only update if (source) url present end end |