Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

find new entries by comparing each entry by url

  • Loading branch information...
commit 3008ceb338df1f4c37a211d0aab8a6ad4f584dbc 1 parent 5931d28
Ed Posnak posnake2000 authored
Showing with 3 additions and 14 deletions.
  1. +3 −14 lib/feedzirra/feed_utilities.rb
17 lib/feedzirra/feed_utilities.rb
@@ -50,23 +50,12 @@ def sanitize_entries!
def find_new_entries_for(feed)
- # this implementation is a hack, which is why it's so ugly.
- # it's to get around the fact that not all feeds have a published date.
- # however, they're always ordered with the newest one first.
- # So we go through the entries just parsed and insert each one as a new entry
- # until we get to one that has the same url as the the newest for the feed
- return feed.entries if self.entries.length == 0
- latest_entry = self.entries.first
- found_new_entries = []
- feed.entries.each do |entry|
- break if entry.url == latest_entry.url
- found_new_entries << entry
- end
- found_new_entries
+ # this algorithm does not optimize based on publication date, but always finds new entries
+ feed.entries.reject {|entry| self.entries.any? {|e| e.url == entry.url} }
def existing_entry?(test_entry)
entries.any? { |entry| entry.url == test_entry.url }
Please sign in to comment.
Something went wrong with that request. Please try again.