i use a lot of rss/atom feeds. by use i mean that i am reading many news-sites, blogs, etc. using their feeds.
for some reason those feeds always contain the last n entries, where n is a fixed number. so a feed contains let’s say the last 10 entries.
this is fine as long as the page (which is represented in the feed) does not get updated too often.
otherwise the following scenario might happen:
the problem is, that these feeds do not provide any guarantees about their “completeness”.
(this is not an “in theory only” problem. once i had this exact problem.a website’s feed only contained the last x (50, iirc) entries, and much more arrived daily. so i kept missing them, and if i wanted to be sure that i saw all of them, i had to manually go through the entries on the site. kind of defeats the purpose of the feed. nowadays i’m using bloglines, which is fetching the feeds a lot more often than i did, so i do not have the problem with that site anymore)
what i would like to see, is feeds that contain all the entries for a specified timeframe.for example for the last 48 hours. they can contain of course more entries, but they would have to guarantee, that they contain at least all the entries for the last 48 hours. which would mean, that if you fetch the feed daily, you will not miss any entries.
for example, let’s do it in django:
django contains a complete feed-framework, with documentation, so first go and read the documentation
as you see, the whole issue of “showing the last n entries” is being handled in the items() method:
(the example from the documentation)
def items(self): return NewsItem.objects.order_by('-pub_date')[:5]
we want to return at least 10 entries, and we want to make sure that we return all the entries for the last 48 hours.
so we could use something like this:
from datetime import datetime, timedelta def items(self): entries = NewsItem.objects.order_by('-pub_date') two_days_ago = datetime.now() - timedelta(days=2) last_entries = entries.filter(pub_date__gte = two_days_ago) if last_entries.count() >= 10: return last_entries else: return entries[:10]
and we’re done.
now if only i could find out how to do it in wordpress (this blog is running on it)
P.S: the code i showed here was not tested extensively, so it might contain bugs. but the basic idea should work.