Class: Pluto::SiteRefresher
- Inherits:
-
Object
- Object
- Pluto::SiteRefresher
- Includes:
- LogUtils::Logging, Models
- Defined in:
- lib/pluto/update/site_refresher.rb
Instance Method Summary collapse
- #debug? ⇒ Boolean
-
#initialize ⇒ SiteRefresher
constructor
A new instance of SiteRefresher.
-
#refresh_sites(opts = {}) ⇒ Object
refresh (fetch+parse+update) all site configs.
Constructor Details
#initialize ⇒ SiteRefresher
Returns a new instance of SiteRefresher.
17 18 19 |
# File 'lib/pluto/update/site_refresher.rb', line 17 def initialize @worker = SiteFetcher.new end |
Instance Method Details
#debug? ⇒ Boolean
21 |
# File 'lib/pluto/update/site_refresher.rb', line 21 def debug?() Pluto.config.debug?; end |
#refresh_sites(opts = {}) ⇒ Object
refresh (fetch+parse+update) all site configs
24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/pluto/update/site_refresher.rb', line 24 def refresh_sites( opts={} ) # refresh (fetch+parse+update) all site configs start_time = Time.now Activity.create!( text: "start update sites (#{Site.count})" ) #### - hack - use order(:id) instead of .all - avoids rails/activerecord 4 warnings Site.order(:id).each do |site| refresh_site_worker( site ) if site.url.present? # note: only update if (source) url present end total_secs = Time.now - start_time Activity.create!( text: "done update sites (#{Site.count}) in #{total_secs}s" ) end |