Mercurial > public > sg101
comparison gpp/forums/feeds.py @ 391:0398aae48807
Another tweak to the forum feeds query; see #191.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Wed, 23 Mar 2011 00:44:06 +0000 |
parents | c3231af55778 |
children | 9af6bd45c1f8 |
comparison
equal
deleted
inserted
replaced
390:e0523e17ea43 | 391:0398aae48807 |
---|---|
65 | 65 |
66 public_forum_ids = Forum.objects.public_forum_ids() | 66 public_forum_ids = Forum.objects.public_forum_ids() |
67 posts = [] | 67 posts = [] |
68 for forum_id in public_forum_ids: | 68 for forum_id in public_forum_ids: |
69 posts.extend(list(Post.objects.filter( | 69 posts.extend(list(Post.objects.filter( |
70 topic__forum__id=forum_id).order_by('-creation_date').select_related(depth=2)[:30])) | 70 topic__forum=forum_id).order_by('-creation_date').select_related( |
71 'topic', 'user', 'topic__forum')[:30])) | |
71 | 72 |
72 posts.sort(key=lambda x: x.creation_date, reverse=True) | 73 posts.sort(key=lambda x: x.creation_date, reverse=True) |
73 return posts[:30] | 74 return posts[:30] |
74 | 75 |
75 else: | 76 else: |
76 return Post.objects.filter(topic__forum__id=obj.id).order_by( | 77 return Post.objects.filter(topic__forum__id=obj.id).order_by( |
77 '-creation_date').select_related(depth=2)[:30] | 78 '-creation_date').select_related('topic', 'user', 'topic__forum')[:30] |
78 | 79 |
79 def item_title(self, item): | 80 def item_title(self, item): |
80 return item.topic.name | 81 return item.topic.name |
81 | 82 |
82 def item_description(self, item): | 83 def item_description(self, item): |