Class: Pluto::FeedRefresher

Inherits:
Object
  • Object
show all
Includes:
LogUtils::Logging, Models
Defined in:
lib/pluto/update/feed_refresher.rb

Overview

note: refresh

refresh will fetch feeds, parse feeds and than update feeds
  (e.g. update is just one operation of refresh)

Instance Method Summary collapse

Constructor Details

#initializeFeedRefresher

Returns a new instance of FeedRefresher.



16
17
18
19
# File 'lib/pluto/update/feed_refresher.rb', line 16

def initialize
  ## @worker = FeedFetcherBasic.new  ## -- simple fetch (strategy); no cache, no cond get etc.
  @worker  = FeedFetcherCondGetWithCache.new
end

Instance Method Details

#debug?Boolean

Returns:

  • (Boolean)


21
# File 'lib/pluto/update/feed_refresher.rb', line 21

def debug?()  Pluto.config.debug?;  end

#refresh_feeds(opts = {}) ⇒ Object

refresh (fetch+parse+update) all feeds



25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/pluto/update/feed_refresher.rb', line 25

def refresh_feeds( opts={} )  # refresh (fetch+parse+update) all feeds

  start_time = Time.now
  Activity.create!( text: "start update feeds (#{Feed.count})" )

  #### - hack - use order(:id) instead of .all - avoids rails/activerecord 4 warnings
  Feed.order(:id).each do |feed|
    refresh_feed_worker( feed )
    ### todo/fix: add catch exception in loop and log to activity log and continue w/ next feed
  end

  total_secs = Time.now - start_time
  Activity.create!( text: "done update feeds (#{Feed.count}) in #{total_secs}s" )
end

#refresh_feeds_for(site_key, opts = {}) ⇒ Object

refresh (fetch+parse+update) feeds for site



41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/pluto/update/feed_refresher.rb', line 41

def refresh_feeds_for( site_key, opts={} ) # refresh (fetch+parse+update) feeds for site

  # -- log update activity
  Activity.create!( text: "update feeds >#{site_key}<" )

  site = Site.find_by_key!( site_key )

  site.feeds.each do |feed|
    refresh_feed_worker( feed )
  end

end