Class: Pluto::Refresher
- Inherits:
-
Object
- Object
- Pluto::Refresher
- Includes:
- LogUtils::Logging, Models
- Defined in:
- lib/pluto/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
Constructor Details
Instance Method Details
#debug=(value) ⇒ Object
13 |
# File 'lib/pluto/refresher.rb', line 13 def debug=(value) @debug = value; end |
#debug? ⇒ Boolean
14 |
# File 'lib/pluto/refresher.rb', line 14 def debug?() @debug || false; end |
#update_feeds(opts = {}) ⇒ Object
update all feeds
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/pluto/refresher.rb', line 17 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 action Action.create!( title: 'update feeds' ) feeds_fetched = Time.now #### - hack - use order(:id) instead of .all - avoids rails/activerecord 4 warnings Site.order(:id).each do |site| site.update_attributes!( fetched: feeds_fetched ) end Feed.order(:id).each do |feed| update_feed_worker( feed ) end end |
#update_feeds_for(site_key, opts = {}) ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/pluto/refresher.rb', line 41 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 action Action.create!( title: "update feeds >#{site_key}<" ) ##### # -- update fetched timestamps for all sites feeds_fetched = Time.now site = Site.find_by_key!( site_key ) site.update_attributes!( fetched: feeds_fetched ) site.feeds.each do |feed| update_feed_worker( feed ) end end |