Fix the slow RSS feed.

Remove the overhead of parsing blog entries when generating the rss
feed. This saves a lot of CPU.

Signed-off-by: Gaël Utard <gael.utard@laposte.net>
Signed-off-by: Maxime Petazzoni <maxime.petazzoni@bulix.org>
stable
Gaël Utard 2010-08-06 16:45:05 +02:00 zatwierdzone przez Maxime Petazzoni
rodzic 66d77a1819
commit 70fa380a9b
2 zmienionych plików z 12 dodań i 6 usunięć

Wyświetl plik

@ -21,15 +21,21 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from models import MapRenderingJob
from django.core.urlresolvers import reverse
import feedparser
from models import MapRenderingJob
def get_latest_blog_posts():
f = feedparser.parse("http://news.maposmatic.org/?feed=rss2")
return f.entries[:5]
def all(request):
d = {}
d['randommap'] = MapRenderingJob.objects.get_random_with_thumbnail()
d['blogposts'] = get_latest_blog_posts()
return d
# Do not add the useless overhead of parsing blog entries when generating
# the rss feed
if request.path == reverse('rss-feed', args=['maps']):
return {}
return {
'randommap': = MapRenderingJob.objects.get_random_with_thumbnail(),
'blogposts': = get_latest_blog_posts()
}

Wyświetl plik

@ -73,7 +73,7 @@ urlpatterns = patterns('',
# Feeds
(r'^feeds/(?P<url>.*)/$', 'django.contrib.syndication.views.feed',
{'feed_dict': feeds}),
{'feed_dict': feeds}, 'rss-feed'),
)
if settings.DEBUG: