Review: Needs Fixing

one comment.

Diff comments:

> 
> === modified file 'pybb/templatetags/pybb_extras.py'
> --- pybb/templatetags/pybb_extras.py  2016-03-02 21:02:38 +0000
> +++ pybb/templatetags/pybb_extras.py  2016-10-10 19:35:39 +0000
> @@ -79,13 +79,15 @@
>  import time
>  @register.inclusion_tag('pybb/last_posts.html', takes_context=True)
>  def pybb_last_posts(context, number = 5):
> -    last_posts = Post.objects.order_by('-created').select_related()[:25]
> +    last_posts = Post.objects.order_by('-created').select_related()[:50]

why not: 
Post.objects.filter(hidden=False).order_by('-created').select_related()[:25] 
and get rid of the check below? That will be way faster since the database does 
the filtering for you.

>      check = []
>      answer = []
>      for post in last_posts:
>          if (post.topic_id not in check) and len(check) < 5:
> -            check = check + [post.topic_id]
> -            answer = answer + [post]
> +            if not post.hidden:
> +                # Gather only not hidden posts
> +                check = check + [post.topic_id]
> +                answer = answer + [post]
>      return {
>          'posts': answer,
>          }


-- 
https://code.launchpad.net/~widelands-dev/widelands-website/anti_spam_2/+merge/308074
Your team Widelands Developers is subscribed to branch lp:widelands-website.

_______________________________________________
Mailing list: https://launchpad.net/~widelands-dev
Post to     : widelands-dev@lists.launchpad.net
Unsubscribe : https://launchpad.net/~widelands-dev
More help   : https://help.launchpad.net/ListHelp

Reply via email to