- c.threads = c.forum.threads.options(
- joinedload('last_post'),
- joinedload('last_post.author'),
- )
+ # nb: This will never show post-less threads. Oh well!
+ threads_q = c.forum.threads \
+ .join(forum_model.Thread.last_post) \
+ .order_by(forum_model.Post.posted_time.desc()) \
+ .options(joinedload('last_post.author'))
+ c.num_threads = threads_q.count()
+ try:
+ c.skip = int(request.params.get('skip', 0))
+ except ValueError:
+ abort(404)
+ c.per_page = 89
+ c.threads = threads_q.offset(c.skip).limit(c.per_page)