Guest User

Untitled

a guest
Feb 21st, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. def refresh_feeds
  2. @channels.each do |channel|
  3. feeds = Feed.find(:all, :conditions => ["disable = 0 and channel_id = ?", channel.id])
  4. feeds.each do |feed|
  5. black_csv = feed.filter_exclude
  6. black_list = black_csv ? black_csv.downcase.split /[\s,]+/ : []
  7. items = SimpleRSS.parse(open(feed.rss)).items rescue continue
  8. items.reject do |item|
  9. item.title.downcase.split( /\W+/ ).any? {|word| black_list.include? word }
  10. end.each do |item|
  11. checksum = item.link.hash
  12. entry = Entry.find(:first, :conditions => ["checksum = ? and feed_id = ?", checksum.to_s, feed.id])
  13. entry = Entry.create :feed_id => feed.id, :title => item.title, :link => item.link,
  14. :description => item.description, :checksum => checksum unless entry
  15. end
  16. end
  17. end
  18. flash[:notice] = "Retrieval completed."
  19. end
Add Comment
Please, Sign In to add comment