Permalink
Browse files

Merge pull request #89 from posnake2000/find_new_entries_for

find new entries by comparing each entry by url
  • Loading branch information...
2 parents 5931d28 + 3008ceb commit 185821573b4ab32cefe3b769e219162173dadb79 @pauldix pauldix committed Mar 3, 2012
Showing with 3 additions and 14 deletions.
  1. +3 −14 lib/feedzirra/feed_utilities.rb
@@ -50,23 +50,12 @@ def sanitize_entries!
private
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} }
end
def existing_entry?(test_entry)
entries.any? { |entry| entry.url == test_entry.url }
end
end
-end
+end

0 comments on commit 1858215

Please sign in to comment.