Quantcast
Viewing latest article 24
Browse Latest Browse All 30

How to add limit for the saved links in feedjira

I use ruby on rails, mongoid and feedjira to parse RSS links.

How to add a limit for the number of saved feed_entries at a time or a limit by the date of the link?For example save only last 10 feed_enties.

My code:

def load_feed_entries  feed = Feedjira::Feed.fetch_and_parse(self.url)  Source.add_entries(feed.entries, self.id)endprivate  def self.add_entries(entries, stream_id)    entries.each do |entry|        unless  FeedEntry.where(guid: entry.id).exists?          FeedEntry.create!(            :link           => entry.url,            :published_at  => entry.published,            :guid          => entry.id,          )        end    end  end

Viewing latest article 24
Browse Latest Browse All 30

Trending Articles